<!DOCTYPE HTML>
<html>
  <head>
    <meta charset="UTF-8">
    <title>TOMTOM</title>
    <script>
      // @JSON_VAR data
      var data = {
        "program": "Tomtom",
        "version": "5.0.2",
        "release": "Thu Aug 30 14:26:08 2018 -0700",
        "cmd": [
          "tomtom", "-oc", "tomtom/tomtom_dreme_merge", "-dist", "pearson",
          "-no-ssc", "meme/meme-chip_merge/dreme_out/dreme.html",
          "/diska/database/jaspar/JASPAR2020_CORE_non-redundant_pfms_meme.txt"
        ],
        "options": {
          "strands": "both",
          "distance_measure": "pearson",
          "threshold_type": "qvalue",
          "threshold_value": 0.5,
          "background_source": "--query--"
        },
        "alphabet": {
          "name": "DNA",
          "like": "dna",
          "ncore": 4,
          "symbols": [
            {
              "symbol": "A",
              "name": "Adenine",
              "colour": "CC0000",
              "complement": "T"
            }, {
              "symbol": "C",
              "name": "Cytosine",
              "colour": "0000CC",
              "complement": "G"
            }, {
              "symbol": "G",
              "name": "Guanine",
              "colour": "FFB300",
              "complement": "C"
            }, {
              "symbol": "T",
              "aliases": "U",
              "name": "Thymine",
              "colour": "008000",
              "complement": "A"
            }, {
              "symbol": "N",
              "aliases": "X.",
              "name": "Any base",
              "equals": "ACGT"
            }, {
              "symbol": "V",
              "name": "Not T",
              "equals": "ACG"
            }, {
              "symbol": "H",
              "name": "Not G",
              "equals": "ACT"
            }, {
              "symbol": "D",
              "name": "Not C",
              "equals": "AGT"
            }, {
              "symbol": "B",
              "name": "Not A",
              "equals": "CGT"
            }, {
              "symbol": "M",
              "name": "Amino",
              "equals": "AC"
            }, {
              "symbol": "R",
              "name": "Purine",
              "equals": "AG"
            }, {
              "symbol": "W",
              "name": "Weak",
              "equals": "AT"
            }, {
              "symbol": "S",
              "name": "Strong",
              "equals": "CG"
            }, {
              "symbol": "Y",
              "name": "Pyrimidine",
              "equals": "CT"
            }, {
              "symbol": "K",
              "name": "Keto",
              "equals": "GT"
            }
          ]
        },
        "background": [0.25, 0.25, 0.25, 0.25],
        "query_dbs": [
          {
            "source": "meme/meme-chip_merge/dreme_out/dreme.html",
            "name": "dreme.html",
            "loaded": 5,
            "excluded": 0,
            "last_modified": "Thu Mar 31 20:15:01 2022"
          }
        ],
        "target_dbs": [
          {
            "source": "/diska/database/jaspar/JASPAR2020_CORE_non-redundant_pfms_meme.txt",
            "name": "JASPAR2020_CORE_non-redundant_pfms_meme.txt",
            "loaded": 1646,
            "excluded": 0,
            "last_modified": "Sat May 30 02:18:37 2020"
          }
        ],
        "queries": [
          {
            "db": 0,
            "id": "AAATYCGG",
            "alt": "DREME-2",
            "len": 8,
            "nsites": 2166,
            "evalue": "2.0e-460",
            "pwm": [
              [0.999965, 1.15415e-05, 1.15415e-05, 1.15415e-05], 
              [0.999965, 1.15415e-05, 1.15415e-05, 1.15415e-05], 
              [0.999965, 1.15415e-05, 1.15415e-05, 1.15415e-05], 
              [1.15415e-05, 1.15415e-05, 1.15415e-05, 0.999965], 
              [1.15415e-05, 0.165747, 1.15415e-05, 0.83423], 
              [1.15415e-05, 0.999965, 1.15415e-05, 1.15415e-05], 
              [1.15415e-05, 1.15415e-05, 0.999965, 1.15415e-05], 
              [1.15415e-05, 1.15415e-05, 0.999965, 1.15415e-05]
            ]
          }, {
            "db": 0,
            "id": "AGTAARTY",
            "alt": "DREME-4",
            "len": 8,
            "nsites": 1737,
            "evalue": "7.9e-351",
            "pwm": [
              [0.999957, 1.43918e-05, 1.43918e-05, 1.43918e-05], 
              [1.43918e-05, 1.43918e-05, 0.999957, 1.43918e-05], 
              [1.43918e-05, 1.43918e-05, 1.43918e-05, 0.999957], 
              [0.999957, 1.43918e-05, 1.43918e-05, 1.43918e-05], 
              [0.999957, 1.43918e-05, 1.43918e-05, 1.43918e-05], 
              [0.550933, 1.43918e-05, 0.449039, 1.43918e-05], 
              [1.43918e-05, 1.43918e-05, 1.43918e-05, 0.999957], 
              [1.43918e-05, 0.686216, 1.43918e-05, 0.313755]
            ]
          }, {
            "db": 0,
            "id": "CCTYCAAG",
            "alt": "DREME-5",
            "len": 8,
            "nsites": 1186,
            "evalue": "2.9e-319",
            "pwm": [
              [2.10775e-05, 0.999937, 2.10775e-05, 2.10775e-05], 
              [2.10775e-05, 0.999937, 2.10775e-05, 2.10775e-05], 
              [2.10775e-05, 2.10775e-05, 2.10775e-05, 0.999937], 
              [2.10775e-05, 0.826258, 2.10775e-05, 0.173699], 
              [2.10775e-05, 0.999937, 2.10775e-05, 2.10775e-05], 
              [0.999937, 2.10775e-05, 2.10775e-05, 2.10775e-05], 
              [0.999937, 2.10775e-05, 2.10775e-05, 2.10775e-05], 
              [2.10775e-05, 2.10775e-05, 0.999937, 2.10775e-05]
            ]
          }, {
            "db": 0,
            "id": "GGGHCCM",
            "alt": "DREME-1",
            "len": 7,
            "nsites": 5670,
            "evalue": "5.2e-1998",
            "pwm": [
              [4.40909e-06, 4.40909e-06, 0.999987, 4.40909e-06], 
              [4.40909e-06, 4.40909e-06, 0.999987, 4.40909e-06], 
              [4.40909e-06, 4.40909e-06, 0.999987, 4.40909e-06], 
              [0.386241, 0.361726, 4.40909e-06, 0.252028], 
              [4.40909e-06, 0.999987, 4.40909e-06, 4.40909e-06], 
              [4.40909e-06, 0.999987, 4.40909e-06, 4.40909e-06], 
              [0.557667, 0.442325, 4.40909e-06, 4.40909e-06]
            ]
          }, {
            "db": 0,
            "id": "TTTCARGR",
            "alt": "DREME-3",
            "len": 8,
            "nsites": 2074,
            "evalue": "4.2e-377",
            "pwm": [
              [1.20534e-05, 1.20534e-05, 1.20534e-05, 0.999964], 
              [1.20534e-05, 1.20534e-05, 1.20534e-05, 0.999964], 
              [1.20534e-05, 1.20534e-05, 1.20534e-05, 0.999964], 
              [1.20534e-05, 0.999964, 1.20534e-05, 1.20534e-05], 
              [0.999964, 1.20534e-05, 1.20534e-05, 1.20534e-05], 
              [0.397293, 1.20534e-05, 0.602683, 1.20534e-05], 
              [1.20534e-05, 1.20534e-05, 0.999964, 1.20534e-05], 
              [0.114279, 1.20534e-05, 0.885697, 1.20534e-05]
            ]
          }
        ],
        "targets": [
          {
            "db": 0,
            "id": "MA0014.3",
            "alt": "PAX5",
            "len": 12,
            "nsites": 1412,
            "url": "http://jaspar.genereg.net/matrix/MA0014.3",
            "pwm": [
              [0.382427, 0.12678, 0.409337, 0.0814569], 
              [0.442621, 0.104826, 0.250708, 0.201844], 
              [0.0127648, 0.106951, 0.871769, 0.0085161], 
              [0.0127648, 0.903637, 0.024095, 0.0595035], 
              [0.0786241, 0.0248039, 0.880267, 0.0163056], 
              [0.066585, 0.0623363, 0.0212622, 0.849816], 
              [0.0113479, 0.0262198, 0.959582, 0.0028505], 
              [0.880267, 0.0276357, 0.0495892, 0.0425077], 
              [0.0226791, 0.924173, 0.0403828, 0.0127648], 
              [0.0488812, 0.765544, 0.0835808, 0.101993], 
              [0.266996, 0.286824, 0.220965, 0.225214], 
              [0.186266, 0.285408, 0.254249, 0.274077]
            ]
          }, {
            "db": 0,
            "id": "MA0163.1",
            "alt": "PLAG1",
            "len": 14,
            "nsites": 18,
            "url": "http://jaspar.genereg.net/matrix/MA0163.1",
            "pwm": [
              [0.00138122, 0.00138122, 0.995856, 0.00138122], 
              [0.167127, 0.00138122, 0.774862, 0.0566303], 
              [0.00138122, 0.00138122, 0.995856, 0.00138122], 
              [0.00138122, 0.00138122, 0.940607, 0.0566303], 
              [0.00138122, 0.774862, 0.222375, 0.00138122], 
              [0.00138122, 0.83011, 0.0566303, 0.111878], 
              [0.222375, 0.553868, 0.0566303, 0.167127], 
              [0.664365, 0.00138122, 0.00138122, 0.332873], 
              [0.609116, 0.277625, 0.111878, 0.00138122], 
              [0.111878, 0.00138122, 0.774862, 0.111878], 
              [0.00138122, 0.00138122, 0.995856, 0.00138122], 
              [0.00138122, 0.00138122, 0.995856, 0.00138122], 
              [0.00138122, 0.00138122, 0.885359, 0.111878], 
              [0.111878, 0.00138122, 0.885359, 0.00138122]
            ]
          }, {
            "db": 0,
            "id": "MA0347.1",
            "alt": "NRG1",
            "len": 20,
            "nsites": 999,
            "url": "http://jaspar.genereg.net/matrix/MA0347.1",
            "pwm": [
              [0.181188, 0.404389, 0.143154, 0.271269], 
              [0.243244, 0.225227, 0.199204, 0.332324], 
              [0.293583, 0.250501, 0.278554, 0.177362], 
              [0.259518, 0.23948, 0.262524, 0.238478], 
              [0.419823, 0.112238, 0.269537, 0.198402], 
              [0.213217, 0.255254, 0.0921078, 0.43942], 
              [0.455891, 0.488954, 0.00904212, 0.0461124], 
              [0.96089, 0.00302772, 0.0360574, 2.50225e-05], 
              [0.00202882, 0.00102692, 0.992912, 0.00403262], 
              [0.00202882, 0.00102692, 0.994915, 0.00202882], 
              [0.0110459, 2.50225e-05, 0.987902, 0.00102692], 
              [0.0710889, 0.0110349, 0.00202682, 0.915849], 
              [0.00403662, 0.930724, 0.00203082, 0.0632087], 
              [0.00302772, 0.820764, 0.00302772, 0.173181], 
              [0.503983, 0.0871903, 0.0390991, 0.369727], 
              [0.245737, 0.202613, 0.23972, 0.31193], 
              [0.124261, 0.303602, 0.269537, 0.3026], 
              [0.224452, 0.0671523, 0.549068, 0.159328], 
              [0.206624, 0.401189, 0.228688, 0.163499], 
              [0.325643, 0.171351, 0.233469, 0.269537]
            ]
          }, {
            "db": 0,
            "id": "MA0587.1",
            "alt": "TCP16",
            "len": 10,
            "nsites": 64,
            "url": "http://jaspar.genereg.net/matrix/MA0587.1",
            "pwm": [
              [0.0471919, 0.000390016, 0.936427, 0.0159906], 
              [0.0159906, 0.0471919, 0.000390016, 0.936427], 
              [0.000390016, 0.000390016, 0.99883, 0.000390016], 
              [0.000390016, 0.000390016, 0.99883, 0.000390016], 
              [0.49961, 0.125195, 0.234399, 0.140796], 
              [0.0159906, 0.936427, 0.0315913, 0.0159906], 
              [0.000390016, 0.99883, 0.000390016, 0.000390016], 
              [0.000390016, 0.99883, 0.000390016, 0.000390016], 
              [0.281201, 0.156396, 0.452808, 0.109594], 
              [0.187598, 0.312402, 0.406006, 0.0939938]
            ]
          }, {
            "db": 0,
            "id": "MA0694.1",
            "alt": "ZBTB7B",
            "len": 12,
            "nsites": 1852,
            "url": "http://jaspar.genereg.net/matrix/MA0694.1",
            "pwm": [
              [0.287795, 0.0858619, 0.429256, 0.197087], 
              [0.0633351, 0.814394, 0.0985132, 0.0237592], 
              [0.168164, 0.00812206, 0.790411, 0.0333027], 
              [0.88482, 0.113719, 1.34982e-05, 0.00144642], 
              [0.00270435, 0.996731, 0.000551469, 1.34982e-05], 
              [1.34982e-05, 0.998881, 0.00109244, 1.34982e-05], 
              [0.691795, 0.30631, 0.000760458, 0.00113444], 
              [0.00270435, 0.996731, 1.34982e-05, 0.000551469], 
              [1.34982e-05, 0.996195, 1.34982e-05, 0.00377829], 
              [0.233839, 0.138037, 0.539297, 0.0888267], 
              [0.677621, 0.107948, 0.0808731, 0.133559], 
              [0.537781, 0.166851, 0.132295, 0.163072]
            ]
          }, {
            "db": 0,
            "id": "MA0695.1",
            "alt": "ZBTB7C",
            "len": 12,
            "nsites": 1017,
            "url": "http://jaspar.genereg.net/matrix/MA0695.1",
            "pwm": [
              [0.267451, 0.116041, 0.455241, 0.161268], 
              [0.119934, 0.667063, 0.140902, 0.0721015], 
              [0.214813, 0.0783519, 0.622974, 0.0838593], 
              [0.798377, 0.176478, 0.00629896, 0.0188467], 
              [0.036918, 0.963033, 2.45797e-05, 2.45797e-05], 
              [2.45797e-05, 0.981606, 0.00484611, 0.0135233], 
              [0.780025, 0.206134, 0.00615398, 0.00768683], 
              [0.0170039, 0.960307, 0.00662793, 0.016061], 
              [0.0719025, 0.813044, 0.0431513, 0.0719025], 
              [0.248527, 0.135571, 0.517656, 0.0982469], 
              [0.477464, 0.208259, 0.117743, 0.196534], 
              [0.327104, 0.309424, 0.19254, 0.170931]
            ]
          }, {
            "db": 0,
            "id": "MA1019.1",
            "alt": "Glyma19g26560.1",
            "len": 9,
            "nsites": 1001,
            "url": "http://jaspar.genereg.net/matrix/MA1019.1",
            "pwm": [
              [0.103911, 0.198806, 0.479497, 0.217785], 
              [0.0190231, 0.0140236, 0.907934, 0.0590191], 
              [0.0861024, 0.0190421, 0.861801, 0.0330547], 
              [0.109014, 0.306994, 0.439981, 0.144011], 
              [0.0420208, 0.881937, 0.0270223, 0.0490201], 
              [0.00302467, 0.995925, 0.00102487, 2.49725e-05], 
              [0.00402457, 0.975927, 2.49725e-05, 0.020023], 
              [0.895935, 0.0170233, 0.0760174, 0.0110239], 
              [0.0170233, 0.843941, 0.05002, 0.0890161]
            ]
          }, {
            "db": 0,
            "id": "MA1031.1",
            "alt": "OJ1581_H09.2",
            "len": 10,
            "nsites": 999,
            "url": "http://jaspar.genereg.net/matrix/MA1031.1",
            "pwm": [
              [0.175182, 0.131143, 0.414398, 0.279276], 
              [0.0740176, 0.14601, 0.334991, 0.44498], 
              [2.50225e-05, 2.50225e-05, 0.928932, 0.0710179], 
              [2.50225e-05, 2.50225e-05, 0.999925, 2.50225e-05], 
              [0.126885, 0.100914, 0.660299, 0.111902], 
              [0.111902, 0.660299, 0.100914, 0.126885], 
              [2.50225e-05, 0.999925, 2.50225e-05, 2.50225e-05], 
              [0.0710179, 0.928932, 2.50225e-05, 2.50225e-05], 
              [0.44498, 0.334991, 0.14601, 0.0740176], 
              [0.279276, 0.414398, 0.131143, 0.175182]
            ]
          }, {
            "db": 0,
            "id": "MA1035.1",
            "alt": "TCP4",
            "len": 8,
            "nsites": 1000,
            "url": "http://jaspar.genereg.net/matrix/MA1035.1",
            "pwm": [
              [0.112014, 0.0010249, 0.774948, 0.112014], 
              [0.0010239, 0.0010239, 0.996928, 0.0010239], 
              [0.0010239, 0.0010239, 0.996928, 0.0010239], 
              [0.830942, 0.167008, 0.0010249, 0.0010249], 
              [0.0010239, 0.996928, 0.0010239, 0.0010239], 
              [0.0010239, 0.996928, 0.0010239, 0.0010239], 
              [0.996925, 0.0010249, 0.0010249, 0.0010249], 
              [0.0010259, 0.996922, 0.0010259, 0.0010259]
            ]
          }, {
            "db": 0,
            "id": "MA1050.1",
            "alt": "OsI_08196",
            "len": 8,
            "nsites": 1001,
            "url": "http://jaspar.genereg.net/matrix/MA1050.1",
            "pwm": [
              [0.00102387, 0.00102387, 0.944986, 0.0529667], 
              [0.0460664, 2.49725e-05, 0.953884, 2.49725e-05], 
              [0.0911069, 0.0911069, 0.726679, 0.0911069], 
              [2.49725e-05, 0.862939, 0.0460204, 0.0910159], 
              [2.49725e-05, 0.999925, 2.49725e-05, 2.49725e-05], 
              [2.49725e-05, 0.999925, 2.49725e-05, 2.49725e-05], 
              [0.899835, 0.05007, 0.05007, 2.49725e-05], 
              [0.00102487, 0.85494, 0.0720178, 0.0720178]
            ]
          }, {
            "db": 0,
            "id": "MA1054.1",
            "alt": "ARALYDRAFT_897773",
            "len": 10,
            "nsites": 1000,
            "url": "http://jaspar.genereg.net/matrix/MA1054.1",
            "pwm": [
              [0.0920158, 0.277997, 0.167008, 0.462979], 
              [0.0270493, 0.0790961, 0.491467, 0.402387], 
              [0.0360214, 0.0040246, 0.876937, 0.0830167], 
              [0.0170233, 0.0070243, 0.956929, 0.0190231], 
              [0.040021, 0.125012, 0.825942, 0.0090241], 
              [0.755949, 0.215003, 0.0070243, 0.0220228], 
              [0.0020248, 0.94893, 0.0470203, 0.0020248], 
              [0.0010259, 0.995921, 0.0020268, 0.0010259], 
              [0.861939, 0.0020248, 0.132012, 0.0040246], 
              [0.020023, 0.906934, 0.0060244, 0.0670183]
            ]
          }, {
            "db": 0,
            "id": "MA1062.2",
            "alt": "TCP15",
            "len": 19,
            "nsites": 827,
            "url": "http://jaspar.genereg.net/matrix/MA1062.2",
            "pwm": [
              [0.338562, 0.170506, 0.206776, 0.284156], 
              [0.307127, 0.220077, 0.192268, 0.280528], 
              [0.44254, 0.153579, 0.154788, 0.249093], 
              [0.345816, 0.170506, 0.191059, 0.292619], 
              [0.119726, 0.0520189, 0.797999, 0.0302566], 
              [0.0133296, 0.0496012, 0.0121208, 0.924948], 
              [0.093127, 0.00486664, 0.889887, 0.0121208], 
              [0.00244793, 0.00123908, 0.995073, 0.00123908], 
              [0.0290477, 0.00365779, 0.952757, 0.0145385], 
              [0.383297, 0.162042, 0.163251, 0.29141], 
              [0.0133296, 0.949129, 0.00486664, 0.0326743], 
              [0.00365779, 0.992655, 0.00123908, 0.00244793], 
              [0.00970306, 0.88505, 0.0060755, 0.0991722], 
              [0.921322, 0.00728435, 0.0580642, 0.0133296], 
              [0.0326743, 0.790745, 0.0556465, 0.120935], 
              [0.297455, 0.18985, 0.165669, 0.347025], 
              [0.256347, 0.160833, 0.140279, 0.44254], 
              [0.297455, 0.188641, 0.205567, 0.308336], 
              [0.286574, 0.211613, 0.169297, 0.332517]
            ]
          }, {
            "db": 0,
            "id": "MA1063.1",
            "alt": "TCP19",
            "len": 10,
            "nsites": 1000,
            "url": "http://jaspar.genereg.net/matrix/MA1063.1",
            "pwm": [
              [0.14801, 0.221003, 0.181007, 0.44998], 
              [0.137011, 0.15101, 0.505974, 0.206004], 
              [0.0320218, 0.0070243, 0.84594, 0.115013], 
              [0.112014, 0.0570193, 0.777947, 0.0530197], 
              [0.190006, 0.282997, 0.408984, 0.118013], 
              [0.109014, 0.738951, 0.0220228, 0.130012], 
              [0.0130237, 0.960929, 0.0010249, 0.0250225], 
              [2.49975e-05, 0.998925, 2.49975e-05, 0.0010249], 
              [0.840941, 0.0290221, 0.128012, 0.0020248], 
              [2.49975e-05, 0.812757, 0.10612, 0.0810979]
            ]
          }, {
            "db": 0,
            "id": "MA1064.1",
            "alt": "TCP2",
            "len": 10,
            "nsites": 1000,
            "url": "http://jaspar.genereg.net/matrix/MA1064.1",
            "pwm": [
              [0.217003, 0.168008, 0.428982, 0.186006], 
              [0.0880162, 0.194006, 0.15401, 0.563969], 
              [0.0350215, 2.49975e-05, 0.843941, 0.121013], 
              [2.49975e-05, 2.49975e-05, 0.980927, 0.0190231], 
              [0.0680182, 0.0780172, 0.520973, 0.332992], 
              [0.332992, 0.520973, 0.0780172, 0.0680182], 
              [0.0190231, 0.980927, 2.49975e-05, 2.49975e-05], 
              [0.121013, 0.843941, 2.49975e-05, 0.0350215], 
              [0.563969, 0.15401, 0.194006, 0.0880162], 
              [0.186006, 0.428982, 0.168008, 0.217003]
            ]
          }, {
            "db": 0,
            "id": "MA1065.2",
            "alt": "TCP20",
            "len": 19,
            "nsites": 970,
            "url": "http://jaspar.genereg.net/matrix/MA1065.2",
            "pwm": [
              [0.338135, 0.175266, 0.221652, 0.264946], 
              [0.312365, 0.235054, 0.19279, 0.259793], 
              [0.41854, 0.170111, 0.160834, 0.250515], 
              [0.342258, 0.18145, 0.204129, 0.272163], 
              [0.109293, 0.0536282, 0.790666, 0.046413], 
              [0.0196118, 0.0546591, 0.0123955, 0.913334], 
              [0.0793986, 0.00724103, 0.904057, 0.00930281], 
              [0.00414935, 0.00105666, 0.991677, 0.00311845], 
              [0.0381658, 0.00311845, 0.942197, 0.0165191], 
              [0.390707, 0.162896, 0.163927, 0.282471], 
              [0.0134264, 0.943228, 0.00414935, 0.0391967], 
              [0.00414935, 0.991677, 2.57705e-05, 0.00414935], 
              [0.00930281, 0.903026, 0.00414935, 0.0835222], 
              [0.914365, 0.00827192, 0.0629063, 0.0144573], 
              [0.0361041, 0.792728, 0.0618754, 0.109293], 
              [0.36906, 0.186605, 0.177327, 0.267008], 
              [0.280409, 0.149495, 0.161865, 0.408231], 
              [0.285563, 0.186605, 0.221652, 0.30618], 
              [0.279378, 0.228868, 0.162896, 0.328858]
            ]
          }, {
            "db": 0,
            "id": "MA1066.1",
            "alt": "TCP23",
            "len": 8,
            "nsites": 1000,
            "url": "http://jaspar.genereg.net/matrix/MA1066.1",
            "pwm": [
              [0.0050245, 0.0030247, 0.965928, 0.0260224], 
              [0.010024, 0.0050245, 0.979927, 0.0050245], 
              [0.0369843, 0.0879282, 0.834108, 0.0409799], 
              [0.0070313, 0.9719, 0.0080322, 0.0130367], 
              [0.0040246, 0.983927, 0.0080242, 0.0040246], 
              [0.0120118, 0.978948, 0.0030217, 0.0060184], 
              [0.95393, 0.010024, 0.0310219, 0.0050245], 
              [0.010014, 0.957971, 0.0110129, 0.0210019]
            ]
          }, {
            "db": 0,
            "id": "MA1067.1",
            "alt": "TCP5",
            "len": 8,
            "nsites": 999,
            "url": "http://jaspar.genereg.net/matrix/MA1067.1",
            "pwm": [
              [0.00202682, 0.00202682, 0.99392, 0.00202682], 
              [0.00202282, 0.00202282, 0.993932, 0.00202282], 
              [0.00202282, 0.00202282, 0.993932, 0.00202282], 
              [0.993932, 0.00202282, 0.00202282, 0.00202282], 
              [0.00202282, 0.993932, 0.00202282, 0.00202282], 
              [0.00202282, 0.993932, 0.00202282, 0.00202282], 
              [0.993932, 0.00202282, 0.00202282, 0.00202282], 
              [0.00202682, 0.745696, 0.00202682, 0.25025]
            ]
          }, {
            "db": 0,
            "id": "MA1095.1",
            "alt": "ARALYDRAFT_495258",
            "len": 8,
            "nsites": 999,
            "url": "http://jaspar.genereg.net/matrix/MA1095.1",
            "pwm": [
              [0.00202682, 0.00202682, 0.99392, 0.00202682], 
              [0.25025, 0.00202682, 0.745696, 0.00202682], 
              [0.00202482, 0.497975, 0.497975, 0.00202482], 
              [0.00202682, 0.99392, 0.00202682, 0.00202682], 
              [0.00202682, 0.99392, 0.00202682, 0.00202682], 
              [0.00202682, 0.99392, 0.00202682, 0.00202682], 
              [0.99392, 0.00202682, 0.00202682, 0.00202682], 
              [0.00302772, 0.990917, 0.00302772, 0.00302772]
            ]
          }, {
            "db": 0,
            "id": "MA1096.1",
            "alt": "ARALYDRAFT_496250",
            "len": 8,
            "nsites": 999,
            "url": "http://jaspar.genereg.net/matrix/MA1096.1",
            "pwm": [
              [0.00302772, 0.00302772, 0.990917, 0.00302772], 
              [0.00202482, 0.00202482, 0.993926, 0.00202482], 
              [0.00202482, 0.00202482, 0.993926, 0.00202482], 
              [0.993926, 0.00202482, 0.00202482, 0.00202482], 
              [0.00202482, 0.993926, 0.00202482, 0.00202482], 
              [0.00202482, 0.993926, 0.00202482, 0.00202482], 
              [0.993926, 0.00202482, 0.00202482, 0.00202482], 
              [0.00302772, 0.990917, 0.00302772, 0.00302772]
            ]
          }, {
            "db": 0,
            "id": "MA1097.1",
            "alt": "ARALYDRAFT_493022",
            "len": 8,
            "nsites": 999,
            "url": "http://jaspar.genereg.net/matrix/MA1097.1",
            "pwm": [
              [0.00302772, 0.00302772, 0.990917, 0.00302772], 
              [0.00302772, 0.00302772, 0.990917, 0.00302772], 
              [0.00302772, 0.332324, 0.661621, 0.00302772], 
              [0.332324, 0.661621, 0.00302772, 0.00302772], 
              [0.00302772, 0.990917, 0.00302772, 0.00302772], 
              [0.00302772, 0.990917, 0.00302772, 0.00302772], 
              [0.990917, 0.00302772, 0.00302772, 0.00302772], 
              [0.00502452, 0.984926, 0.00502452, 0.00502452]
            ]
          }, {
            "db": 0,
            "id": "MA1098.1",
            "alt": "ARALYDRAFT_484486",
            "len": 8,
            "nsites": 999,
            "url": "http://jaspar.genereg.net/matrix/MA1098.1",
            "pwm": [
              [0.00202682, 0.00202682, 0.99392, 0.00202682], 
              [0.25025, 0.00202682, 0.745696, 0.00202682], 
              [0.00202482, 0.497975, 0.497975, 0.00202482], 
              [0.00202682, 0.99392, 0.00202682, 0.00202682], 
              [0.00202682, 0.99392, 0.00202682, 0.00202682], 
              [0.00202682, 0.99392, 0.00202682, 0.00202682], 
              [0.99392, 0.00202682, 0.00202682, 0.00202682], 
              [0.00302772, 0.990917, 0.00302772, 0.00302772]
            ]
          }, {
            "db": 0,
            "id": "MA1282.1",
            "alt": "PTF1",
            "len": 13,
            "nsites": 130,
            "url": "http://jaspar.genereg.net/matrix/MA1282.1",
            "pwm": [
              [0.130861, 0.0693699, 0.738087, 0.0616829], 
              [0.0463107, 0.0847421, 0.0539968, 0.81495], 
              [0.0847421, 0.0693699, 0.745773, 0.100115], 
              [0.00019216, 0.00019216, 0.991737, 0.00787825], 
              [0.00019216, 0.00019216, 0.999424, 0.00019216], 
              [0.00019216, 0.00019216, 0.999424, 0.00019216], 
              [0.761145, 0.161606, 0.00019216, 0.077056], 
              [0.00019216, 0.991737, 0.00019216, 0.00787825], 
              [0.00019216, 0.999424, 0.00019216, 0.00019216], 
              [0.92256, 0.00019216, 0.077056, 0.00019216], 
              [0.00019216, 0.8995, 0.0463107, 0.0539968], 
              [0.438317, 0.123175, 0.0924292, 0.34608], 
              [0.384512, 0.077056, 0.207725, 0.330707]
            ]
          }, {
            "db": 0,
            "id": "MA1283.1",
            "alt": "TCP14",
            "len": 20,
            "nsites": 47,
            "url": "http://jaspar.genereg.net/matrix/MA1283.1",
            "pwm": [
              [0.658704, 0.106688, 0.106688, 0.12792], 
              [0.27654, 0.340234, 0.27654, 0.106688], 
              [0.849788, 0.000530786, 0.0854561, 0.0642253], 
              [0.29777, 0.0429934, 0.382697, 0.27654], 
              [0.764862, 0.0429934, 0.0854561, 0.106688], 
              [0.106688, 0.106688, 0.595011, 0.191613], 
              [0.212845, 0.29777, 0.382697, 0.106688], 
              [0.467622, 0.0429934, 0.255308, 0.234077], 
              [0.0429934, 0.212845, 0.340234, 0.403927], 
              [0.000530786, 0.000530786, 0.998408, 0.000530786], 
              [0.000530786, 0.000530786, 0.000530786, 0.998408], 
              [0.0429934, 0.000530786, 0.955945, 0.000530786], 
              [0.000530786, 0.000530786, 0.998408, 0.000530786], 
              [0.000530786, 0.000530786, 0.998408, 0.000530786], 
              [0.403927, 0.000530786, 0.382697, 0.212845], 
              [0.000530786, 0.998408, 0.000530786, 0.000530786], 
              [0.000530786, 0.998408, 0.000530786, 0.000530786], 
              [0.000530786, 0.998408, 0.000530786, 0.000530786], 
              [0.913482, 0.000530786, 0.0854561, 0.000530786], 
              [0.000530786, 0.998408, 0.000530786, 0.000530786]
            ]
          }, {
            "db": 0,
            "id": "MA1284.1",
            "alt": "TCP1",
            "len": 30,
            "nsites": 95,
            "url": "http://jaspar.genereg.net/matrix/MA1284.1",
            "pwm": [
              [0.378811, 0.0738694, 0.168507, 0.378811], 
              [0.0423236, 0.0738694, 0.883544, 0.000262881], 
              [0.000262881, 0.0633545, 0.0528395, 0.883544], 
              [0.000262881, 0.000262881, 0.999211, 0.000262881], 
              [0.000262881, 0.000262881, 0.999211, 0.000262881], 
              [0.000262881, 0.000262881, 0.999211, 0.000262881], 
              [0.0843853, 0.568086, 0.0843853, 0.263144], 
              [0.000262881, 0.988696, 0.0107778, 0.000262881], 
              [0.000262881, 0.999211, 0.000262881, 0.000262881], 
              [0.0949003, 0.862513, 0.000262881, 0.0423236], 
              [0.547055, 0.273659, 0.0843853, 0.0949003], 
              [0.157992, 0.641693, 0.0212937, 0.179022], 
              [0.168507, 0.357782, 0.231598, 0.242113], 
              [0.136961, 0.231598, 0.126446, 0.504995], 
              [0.221083, 0.389327, 0.157992, 0.231598], 
              [0.210568, 0.357782, 0.105415, 0.326236], 
              [0.168507, 0.29469, 0.0843853, 0.452419], 
              [0.242113, 0.452419, 0.11593, 0.189538], 
              [0.263144, 0.189538, 0.126446, 0.420873], 
              [0.168507, 0.326236, 0.263144, 0.242113], 
              [0.231598, 0.231598, 0.179022, 0.357782], 
              [0.242113, 0.273659, 0.11593, 0.368296], 
              [0.157992, 0.136961, 0.378811, 0.326236], 
              [0.210568, 0.11593, 0.420873, 0.252629], 
              [0.157992, 0.157992, 0.378811, 0.305205], 
              [0.29469, 0.378811, 0.105415, 0.221083], 
              [0.200053, 0.389327, 0.157992, 0.252629], 
              [0.231598, 0.284175, 0.189538, 0.29469], 
              [0.378811, 0.200053, 0.221083, 0.200053], 
              [0.126446, 0.368296, 0.0843853, 0.420873]
            ]
          }, {
            "db": 0,
            "id": "MA1285.1",
            "alt": "At2g45680",
            "len": 21,
            "nsites": 395,
            "url": "http://jaspar.genereg.net/matrix/MA1285.1",
            "pwm": [
              [0.194951, 0.486016, 0.151924, 0.16711], 
              [0.215199, 0.518919, 0.144331, 0.121552], 
              [0.493609, 0.200013, 0.129145, 0.177233], 
              [0.164579, 0.225322, 0.124083, 0.486016], 
              [0.126613, 0.139269, 0.197481, 0.536636], 
              [0.260756, 0.146861, 0.106365, 0.486016], 
              [0.164579, 0.232915, 0.382245, 0.220261], 
              [0.232915, 0.430334, 0.0759931, 0.260756], 
              [0.225322, 0.42021, 0.0861175, 0.268349], 
              [0.11649, 0.0329659, 0.840357, 0.0101877], 
              [0.00259463, 0.0481521, 0.00259463, 0.946659], 
              [0.040559, 6.32751e-05, 0.959314, 6.32751e-05], 
              [0.00259463, 6.32751e-05, 0.997279, 6.32751e-05], 
              [0.0608069, 6.32751e-05, 0.936535, 0.00259463], 
              [0.134206, 0.245571, 0.0582765, 0.561946], 
              [6.32751e-05, 0.982093, 6.32751e-05, 0.0177808], 
              [0.00512499, 0.994748, 6.32751e-05, 6.32751e-05], 
              [0.00259463, 0.939067, 0.00259463, 0.0557452], 
              [0.901101, 0.00259463, 0.0962419, 6.32751e-05], 
              [0.00512499, 0.875791, 0.0279042, 0.0911792], 
              [0.263288, 0.450582, 0.0911792, 0.194951]
            ]
          }, {
            "db": 0,
            "id": "MA1286.1",
            "alt": "TCP24",
            "len": 12,
            "nsites": 594,
            "url": "http://jaspar.genereg.net/matrix/MA1286.1",
            "pwm": [
              [0.257575, 0.136383, 0.36025, 0.245792], 
              [0.190246, 0.181829, 0.158264, 0.46966], 
              [0.1246, 0.168364, 0.329953, 0.377083], 
              [0.0202407, 0.018558, 0.930861, 0.03034], 
              [4.20805e-05, 4.20805e-05, 0.99819, 0.0017258], 
              [4.20805e-05, 4.20805e-05, 0.999874, 4.20805e-05], 
              [0.887098, 0.0404393, 0.0438057, 0.0286573], 
              [4.20805e-05, 0.999874, 4.20805e-05, 4.20805e-05], 
              [4.20805e-05, 0.999874, 4.20805e-05, 4.20805e-05], 
              [0.954426, 4.20805e-05, 0.0454894, 4.20805e-05], 
              [0.0269735, 0.942644, 0.0151915, 0.0151915], 
              [0.32827, 0.32322, 0.0673707, 0.28114]
            ]
          }, {
            "db": 0,
            "id": "MA1287.1",
            "alt": "TCP21",
            "len": 14,
            "nsites": 598,
            "url": "http://jaspar.genereg.net/matrix/MA1287.1",
            "pwm": [
              [0.31437, 0.128783, 0.165566, 0.39128], 
              [0.05856, 0.0084014, 0.932996, 4.1799e-05], 
              [4.1799e-05, 0.0334812, 4.1799e-05, 0.966435], 
              [4.1799e-05, 4.1799e-05, 0.999875, 4.1799e-05], 
              [4.1799e-05, 4.1799e-05, 0.999875, 4.1799e-05], 
              [0.0903277, 0.00171352, 0.869461, 0.0384974], 
              [0.257524, 0.483239, 0.0552166, 0.204021], 
              [4.1799e-05, 0.998203, 4.1799e-05, 0.00171352], 
              [0.0251216, 0.973123, 4.1799e-05, 0.00171352], 
              [0.103703, 0.693906, 0.0234489, 0.178942], 
              [0.708953, 0.0619045, 0.147174, 0.0819681], 
              [0.0970156, 0.565164, 0.10872, 0.2291], 
              [0.255852, 0.250836, 0.197333, 0.295979], 
              [0.269228, 0.173926, 0.16055, 0.396297]
            ]
          }, {
            "db": 0,
            "id": "MA1288.1",
            "alt": "At1g72010",
            "len": 13,
            "nsites": 595,
            "url": "http://jaspar.genereg.net/matrix/MA1288.1",
            "pwm": [
              [0.381491, 0.156319, 0.183204, 0.278987], 
              [0.277306, 0.146235, 0.188245, 0.388212], 
              [0.0202066, 0.00340244, 0.976349, 4.20097e-05], 
              [4.20097e-05, 0.0420519, 4.20097e-05, 0.957864], 
              [0.00172273, 4.20097e-05, 0.998193, 4.20097e-05], 
              [4.20097e-05, 4.20097e-05, 0.999874, 4.20097e-05], 
              [0.0958239, 0.00508316, 0.862082, 0.0370108], 
              [0.289069, 0.381491, 0.0975046, 0.231936], 
              [4.20097e-05, 0.999874, 4.20097e-05, 4.20097e-05], 
              [0.00172273, 0.998193, 4.20097e-05, 4.20097e-05], 
              [0.0756593, 0.737733, 0.0151655, 0.171442], 
              [0.741093, 0.0420519, 0.146235, 0.0706181], 
              [0.0857416, 0.539447, 0.117669, 0.257142]
            ]
          }, {
            "db": 0,
            "id": "MA1289.1",
            "alt": "TCP3",
            "len": 13,
            "nsites": 582,
            "url": "http://jaspar.genereg.net/matrix/MA1289.1",
            "pwm": [
              [0.283499, 0.11858, 0.359088, 0.238834], 
              [0.209629, 0.163245, 0.132322, 0.494803], 
              [0.0996818, 0.152938, 0.317857, 0.429522], 
              [0.00347836, 0.00347836, 0.967231, 0.0258115], 
              [4.29479e-05, 4.29479e-05, 0.999871, 4.29479e-05], 
              [4.29479e-05, 4.29479e-05, 0.999871, 4.29479e-05], 
              [0.864155, 0.0876569, 4.29479e-05, 0.0481447], 
              [4.29479e-05, 0.999871, 4.29479e-05, 4.29479e-05], 
              [4.29479e-05, 0.999871, 4.29479e-05, 4.29479e-05], 
              [0.93459, 4.29479e-05, 0.0653237, 4.29479e-05], 
              [0.00176065, 0.963795, 0.0103502, 0.0240938], 
              [0.369395, 0.264602, 0.0876569, 0.278346], 
              [0.336755, 0.127169, 0.178706, 0.35737]
            ]
          }, {
            "db": 0,
            "id": "MA1290.1",
            "alt": "TCP17",
            "len": 11,
            "nsites": 108,
            "url": "http://jaspar.genereg.net/matrix/MA1290.1",
            "pwm": [
              [0.0742367, 0.0557359, 0.851295, 0.0187331], 
              [0.0187331, 0.0464844, 0.000231267, 0.934551], 
              [0.000231267, 0.0187331, 0.971554, 0.0094817], 
              [0.000231267, 0.000231267, 0.980804, 0.0187331], 
              [0.0279836, 0.000231267, 0.185245, 0.78654], 
              [0.0094817, 0.990056, 0.000231267, 0.000231267], 
              [0.000231267, 0.999306, 0.000231267, 0.000231267], 
              [0.0094817, 0.980804, 0.0094817, 0.000231267], 
              [0.157493, 0.740287, 0.0464844, 0.0557359], 
              [0.832793, 0.0557359, 0.0557359, 0.0557359], 
              [0.0834872, 0.712535, 0.0834872, 0.12049]
            ]
          }, {
            "db": 0,
            "id": "MA1291.1",
            "alt": "TCP7",
            "len": 11,
            "nsites": 588,
            "url": "http://jaspar.genereg.net/matrix/MA1291.1",
            "pwm": [
              [0.00174322, 4.25098e-05, 0.998172, 4.25098e-05], 
              [4.25098e-05, 0.0255482, 4.25098e-05, 0.974367], 
              [0.115669, 4.25098e-05, 0.884246, 4.25098e-05], 
              [4.25098e-05, 4.25098e-05, 0.999872, 4.25098e-05], 
              [0.00684435, 0.00174322, 0.991371, 4.25098e-05], 
              [0.387732, 0.156479, 0.275506, 0.180284], 
              [0.0374511, 0.874044, 4.25098e-05, 0.0884625], 
              [0.00344293, 0.996472, 4.25098e-05, 4.25098e-05], 
              [0.0425523, 0.94546, 0.00684435, 0.00514364], 
              [0.766919, 0.0510538, 0.127572, 0.0544553], 
              [0.0714594, 0.545868, 0.112268, 0.270405]
            ]
          }, {
            "db": 0,
            "id": "MA1410.1",
            "alt": "StBRC1",
            "len": 10,
            "nsites": 100001,
            "url": "http://jaspar.genereg.net/matrix/MA1410.1",
            "pwm": [
              [0.114979, 0.236828, 0.365976, 0.282217], 
              [0.0243702, 0.0208202, 0.930149, 0.0246602], 
              [0.00419025, 0.00447025, 0.984999, 0.00634024], 
              [0.0440202, 0.14768, 0.750889, 0.0574102], 
              [0.0460202, 0.5971, 0.31742, 0.0394602], 
              [0.00925024, 0.976599, 0.00962024, 0.00453025], 
              [0.0657092, 0.91693, 0.0103102, 0.00705024], 
              [0.30634, 0.5283, 0.11378, 0.0515802], 
              [0.165898, 0.520865, 0.0976492, 0.215588], 
              [0.14072, 0.48745, 0.17972, 0.19211]
            ]
          }, {
            "db": 0,
            "id": "MA1428.1",
            "alt": "TCP8",
            "len": 9,
            "nsites": 998,
            "url": "http://jaspar.genereg.net/matrix/MA1428.1",
            "pwm": [
              [0.172353, 0.240482, 0.373735, 0.213431], 
              [0.0411439, 0.0150685, 0.803355, 0.140432], 
              [0.143298, 0.0290801, 0.726405, 0.101217], 
              [0.15016, 0.255254, 0.433415, 0.16117], 
              [0.16049, 0.653922, 0.0632087, 0.12238], 
              [0.0321178, 0.965826, 0.00203085, 2.50476e-05], 
              [0.020063, 0.903742, 2.50476e-05, 0.0761694], 
              [0.865669, 0.00102695, 0.11324, 0.020063], 
              [0.0320538, 0.725678, 0.0971123, 0.145156]
            ]
          }, {
            "db": 0,
            "id": "MA1430.1",
            "alt": "TB1",
            "len": 10,
            "nsites": 999,
            "url": "http://jaspar.genereg.net/matrix/MA1430.1",
            "pwm": [
              [2.50225e-05, 2.50225e-05, 0.999925, 2.50225e-05], 
              [2.50225e-05, 2.50225e-05, 0.999925, 2.50225e-05], 
              [0.0841846, 0.308611, 0.519011, 0.0881922], 
              [2.50225e-05, 0.999925, 2.50225e-05, 2.50225e-05], 
              [2.50225e-05, 0.999925, 2.50225e-05, 2.50225e-05], 
              [0.0410619, 0.958888, 2.50225e-05, 2.50225e-05], 
              [0.0371323, 0.955797, 2.50225e-05, 0.00704532], 
              [0.153163, 0.839781, 0.00402862, 0.00302772], 
              [0.143154, 0.648609, 0.0130367, 0.1952], 
              [0.385758, 0.405796, 0.119251, 0.0891941]
            ]
          }, {
            "db": 0,
            "id": "MA1494.1",
            "alt": "HNF4A(var.2)",
            "len": 15,
            "nsites": 650,
            "url": "http://jaspar.genereg.net/matrix/MA1494.1",
            "pwm": [
              [0.326142, 0.107714, 0.499962, 0.0661823], 
              [0.452601, 0.0105628, 0.526273, 0.0105628], 
              [0.00456276, 0.00305499, 0.981787, 0.0105948], 
              [0.003019, 0.00152823, 0.0253696, 0.970083], 
              [0.111628, 0.726489, 0.0457904, 0.116092], 
              [0.0103769, 0.961486, 0.00594555, 0.022192], 
              [0.989248, 3.84556e-05, 0.0106748, 3.84556e-05], 
              [0.990754, 0.00156022, 0.00308199, 0.00460375], 
              [0.992264, 3.84556e-05, 0.00765928, 3.84556e-05], 
              [3.84556e-05, 3.84556e-05, 0.998351, 0.00157222], 
              [0.00421581, 3.84556e-05, 0.906584, 0.0891607], 
              [3.84556e-05, 0.00592855, 0.035379, 0.958654], 
              [0.00291601, 0.936585, 0.0101089, 0.0503907], 
              [0.699179, 0.0075563, 0.279694, 0.0135704], 
              [0.267278, 0.33332, 0.155161, 0.244241]
            ]
          }, {
            "db": 0,
            "id": "MA1548.1",
            "alt": "PLAGL2",
            "len": 10,
            "nsites": 999,
            "url": "http://jaspar.genereg.net/matrix/MA1548.1",
            "pwm": [
              [0.224227, 0.224227, 0.224227, 0.327319], 
              [0.0390991, 0.0390991, 0.814572, 0.107228], 
              [2.50225e-05, 2.50225e-05, 0.999925, 2.50225e-05], 
              [2.50225e-05, 0.151161, 0.848789, 2.50225e-05], 
              [2.50225e-05, 0.799745, 0.200205, 2.50225e-05], 
              [2.50225e-05, 0.999925, 2.50225e-05, 2.50225e-05], 
              [2.50225e-05, 0.999925, 2.50225e-05, 2.50225e-05], 
              [2.50225e-05, 0.925858, 2.50225e-05, 0.0740916], 
              [0.090287, 0.686014, 0.0250975, 0.198601], 
              [0.210214, 0.210214, 0.210214, 0.369357]
            ]
          }, {
            "db": 0,
            "id": "MA1655.1",
            "alt": "ZNF341",
            "len": 12,
            "nsites": 18728,
            "url": "http://jaspar.genereg.net/matrix/MA1655.1",
            "pwm": [
              [0.227787, 0.227253, 0.30959, 0.23537], 
              [0.273227, 0.116404, 0.471592, 0.138777], 
              [0.0803089, 0.109089, 0.733604, 0.0769979], 
              [0.911679, 0.0509941, 0.0273932, 0.00993328], 
              [0.945105, 0.0112683, 0.0307572, 0.0128693], 
              [0.0160732, 0.897744, 0.055159, 0.0310242], 
              [0.941207, 0.0213062, 0.0249902, 0.0124963], 
              [0.00897229, 0.0191702, 0.959629, 0.0122293], 
              [0.0121223, 0.961284, 0.0144183, 0.0121753], 
              [0.164566, 0.58447, 0.122224, 0.128739], 
              [0.283266, 0.236598, 0.249466, 0.230671], 
              [0.200555, 0.30676, 0.303877, 0.188808]
            ]
          }, {
            "db": 0,
            "id": "MA1690.1",
            "alt": "ARF25",
            "len": 15,
            "nsites": 19440,
            "url": "http://jaspar.genereg.net/matrix/MA1690.1",
            "pwm": [
              [0.387139, 0.395575, 0.063324, 0.153961], 
              [0.693825, 0.0899188, 0.100567, 0.11569], 
              [0.486522, 0.120474, 0.335648, 0.057357], 
              [0.246296, 0.414145, 0.205607, 0.133952], 
              [0.0661529, 0.0328201, 0.87047, 0.0305571], 
              [0.0252072, 0.00689425, 0.963113, 0.00478526], 
              [0.00920924, 0.00622525, 0.981117, 0.00344827], 
              [0.361676, 0.0134272, 0.615893, 0.00900324], 
              [0.0309681, 0.00879724, 0.953031, 0.00720325], 
              [0.938576, 0.00720325, 0.052522, 0.00169928], 
              [0.00612225, 0.980089, 0.0101352, 0.00365327], 
              [0.955963, 0.00493926, 0.0362151, 0.00288227], 
              [0.466871, 0.3125, 0.05031, 0.170319], 
              [0.0693939, 0.130402, 0.434876, 0.365328], 
              [0.100618, 0.120629, 0.41183, 0.366923]
            ]
          }, {
            "db": 0,
            "id": "MA1695.1",
            "alt": "ARF36",
            "len": 14,
            "nsites": 11250,
            "url": "http://jaspar.genereg.net/matrix/MA1695.1",
            "pwm": [
              [0.385155, 0.121601, 0.397332, 0.0959124], 
              [0.139734, 0.536441, 0.146312, 0.177512], 
              [0.0983123, 0.0706686, 0.788084, 0.0429348], 
              [0.0389349, 0.0107581, 0.92915, 0.021158], 
              [0.0467578, 0.00764615, 0.939372, 0.00622417], 
              [0.133957, 0.0115581, 0.847817, 0.00666916], 
              [0.0480908, 0.0106691, 0.932883, 0.00835815], 
              [0.931816, 0.00773515, 0.0579577, 0.0024912], 
              [0.00729116, 0.980616, 0.00738016, 0.00471318], 
              [0.963461, 0.00471318, 0.028091, 0.00373519], 
              [0.303022, 0.396088, 0.0528908, 0.248], 
              [0.0831125, 0.140979, 0.650929, 0.124979], 
              [0.0966234, 0.128357, 0.217956, 0.557064], 
              [0.113157, 0.597597, 0.0674686, 0.221778]
            ]
          }
        ],
        "all_matches": [
          {
            "idx": 3,
            "matches": [
              {
                "idx": 8,
                "rc": false,
                "off": 0,
                "pv": "1.06e-05",
                "ev": "1.75e-02",
                "qv": "1.01e-02"
              }, {
                "idx": 7,
                "rc": false,
                "off": 2,
                "pv": "1.26e-05",
                "ev": "2.08e-02",
                "qv": "1.01e-02"
              }, {
                "idx": 19,
                "rc": false,
                "off": 0,
                "pv": "1.71e-05",
                "ev": "2.81e-02",
                "qv": "1.01e-02"
              }, {
                "idx": 29,
                "rc": true,
                "off": 3,
                "pv": "2.66e-05",
                "ev": "4.38e-02",
                "qv": "1.01e-02"
              }, {
                "idx": 10,
                "rc": false,
                "off": 2,
                "pv": "2.71e-05",
                "ev": "4.46e-02",
                "qv": "1.01e-02"
              }, {
                "idx": 16,
                "rc": false,
                "off": 0,
                "pv": "2.82e-05",
                "ev": "4.64e-02",
                "qv": "1.01e-02"
              }, {
                "idx": 18,
                "rc": false,
                "off": 0,
                "pv": "2.82e-05",
                "ev": "4.64e-02",
                "qv": "1.01e-02"
              }, {
                "idx": 13,
                "rc": false,
                "off": 2,
                "pv": "3.42e-05",
                "ev": "5.62e-02",
                "qv": "1.01e-02"
              }, {
                "idx": 21,
                "rc": false,
                "off": 3,
                "pv": "3.73e-05",
                "ev": "6.14e-02",
                "qv": "1.01e-02"
              }, {
                "idx": 27,
                "rc": false,
                "off": 4,
                "pv": "3.73e-05",
                "ev": "6.14e-02",
                "qv": "1.01e-02"
              }, {
                "idx": 9,
                "rc": false,
                "off": 0,
                "pv": "5.75e-05",
                "ev": "9.46e-02",
                "qv": "1.29e-02"
              }, {
                "idx": 15,
                "rc": false,
                "off": 0,
                "pv": "5.75e-05",
                "ev": "9.46e-02",
                "qv": "1.29e-02"
              }, {
                "idx": 28,
                "rc": false,
                "off": 3,
                "pv": "5.98e-05",
                "ev": "9.84e-02",
                "qv": "1.29e-02"
              }, {
                "idx": 32,
                "rc": false,
                "off": 1,
                "pv": "6.92e-05",
                "ev": "1.14e-01",
                "qv": "1.40e-02"
              }, {
                "idx": 25,
                "rc": false,
                "off": 3,
                "pv": "1.09e-04",
                "ev": "1.79e-01",
                "qv": "2.03e-02"
              }, {
                "idx": 26,
                "rc": false,
                "off": 3,
                "pv": "1.13e-04",
                "ev": "1.85e-01",
                "qv": "2.03e-02"
              }, {
                "idx": 12,
                "rc": false,
                "off": 2,
                "pv": "1.93e-04",
                "ev": "3.17e-01",
                "qv": "3.15e-02"
              }, {
                "idx": 6,
                "rc": false,
                "off": 1,
                "pv": "1.94e-04",
                "ev": "3.19e-01",
                "qv": "3.15e-02"
              }, {
                "idx": 35,
                "rc": true,
                "off": 3,
                "pv": "2.58e-04",
                "ev": "4.25e-01",
                "qv": "4.00e-02"
              }, {
                "idx": 31,
                "rc": true,
                "off": 3,
                "pv": "2.96e-04",
                "ev": "4.87e-01",
                "qv": "4.37e-02"
              }, {
                "idx": 22,
                "rc": true,
                "off": 2,
                "pv": "3.23e-04",
                "ev": "5.31e-01",
                "qv": "4.56e-02"
              }, {
                "idx": 17,
                "rc": false,
                "off": 0,
                "pv": "3.65e-04",
                "ev": "6.02e-01",
                "qv": "4.63e-02"
              }, {
                "idx": 20,
                "rc": false,
                "off": 0,
                "pv": "3.65e-04",
                "ev": "6.02e-01",
                "qv": "4.63e-02"
              }, {
                "idx": 3,
                "rc": true,
                "off": 2,
                "pv": "3.83e-04",
                "ev": "6.31e-01",
                "qv": "4.63e-02"
              }, {
                "idx": 33,
                "rc": false,
                "off": 0,
                "pv": "4.80e-04",
                "ev": "7.90e-01",
                "qv": "5.38e-02"
              }, {
                "idx": 30,
                "rc": true,
                "off": 2,
                "pv": "8.09e-04",
                "ev": "1.33e+00",
                "qv": "7.26e-02"
              }, {
                "idx": 23,
                "rc": true,
                "off": 21,
                "pv": "8.35e-04",
                "ev": "1.37e+00",
                "qv": "7.26e-02"
              }, {
                "idx": 14,
                "rc": false,
                "off": 6,
                "pv": "8.37e-04",
                "ev": "1.38e+00",
                "qv": "7.26e-02"
              }, {
                "idx": 1,
                "rc": true,
                "off": 7,
                "pv": "9.53e-04",
                "ev": "1.57e+00",
                "qv": "7.79e-02"
              }, {
                "idx": 11,
                "rc": false,
                "off": 6,
                "pv": "9.59e-04",
                "ev": "1.58e+00",
                "qv": "7.79e-02"
              }, {
                "idx": 24,
                "rc": false,
                "off": 11,
                "pv": "2.40e-03",
                "ev": "3.95e+00",
                "qv": "1.62e-01"
              }, {
                "idx": 4,
                "rc": false,
                "off": 0,
                "pv": "4.11e-03",
                "ev": "6.76e+00",
                "qv": "2.38e-01"
              }, {
                "idx": 5,
                "rc": false,
                "off": 0,
                "pv": "4.11e-03",
                "ev": "6.76e+00",
                "qv": "2.38e-01"
              }, {
                "idx": 0,
                "rc": false,
                "off": 4,
                "pv": "4.45e-03",
                "ev": "7.32e+00",
                "qv": "2.54e-01"
              }, {
                "idx": 2,
                "rc": false,
                "off": 8,
                "pv": "4.67e-03",
                "ev": "7.69e+00",
                "qv": "2.62e-01"
              }, {
                "idx": 34,
                "rc": false,
                "off": 0,
                "pv": "4.76e-03",
                "ev": "7.83e+00",
                "qv": "2.62e-01"
              }, {
                "idx": 36,
                "rc": false,
                "off": 0,
                "pv": "8.39e-03",
                "ev": "1.38e+01",
                "qv": "4.33e-01"
              }, {
                "idx": 38,
                "rc": false,
                "off": 4,
                "pv": "8.94e-03",
                "ev": "1.47e+01",
                "qv": "4.53e-01"
              }, {
                "idx": 37,
                "rc": false,
                "off": 6,
                "pv": "9.05e-03",
                "ev": "1.49e+01",
                "qv": "4.53e-01"
              }
            ]
          }
        ],
        "runtime": {
          "host": "192.168.2.3",
          "when": "Thu Mar 31 20:26:43 2022",
          "cycles": 1869021,
          "seconds": 1.869
        }
      };
    </script>
    <script>
var site_url = "http://meme-suite.org";
</script>
    <script>
/*
 * $
 *
 * Shorthand function for getElementById
 */
function $(el) {
  return document.getElementById(el);
}


/*
 * See http://stackoverflow.com/a/5450113/66387
 * Does string multiplication like the perl x operator.
 */
function string_mult(pattern, count) {
    if (count < 1) return '';
    var result = '';
    while (count > 1) {
        if (count & 1) result += pattern;
        count >>= 1, pattern += pattern;
    }
    return result + pattern;
}

/*
 * See http://stackoverflow.com/questions/814613/how-to-read-get-data-from-a-url-using-javascript
 * Slightly modified with information from
 * https://developer.mozilla.org/en/DOM/window.location
 */
function parse_params() {
  "use strict";
  var search, queryStart, queryEnd, query, params, nvPairs, i, nv, n, v;
  search = window.location.search;
  queryStart = search.indexOf("?") + 1;
  queryEnd   = search.indexOf("#") + 1 || search.length + 1;
  query      = search.slice(queryStart, queryEnd - 1);

  if (query === search || query === "") return {};

  params  = {};
  nvPairs = query.replace(/\+/g, " ").split("&");

  for (i = 0; i < nvPairs.length; i++) {
    nv = nvPairs[i].split("=");
    n  = decodeURIComponent(nv[0]);
    v  = decodeURIComponent(nv[1]);
    // allow a name to be used multiple times
    // storing each value in the array
    if (!(n in params)) {
      params[n] = [];
    }
    params[n].push(nv.length === 2 ? v : null);
  }
  return params;
}

/*
 * coords
 *
 * Calculates the x and y offset of an element.
 * From http://www.quirksmode.org/js/findpos.html
 * with alterations to take into account scrolling regions
 */
function coords(elem) {
  var myX = myY = 0;
  if (elem.getBoundingClientRect) {
    var rect;
    rect = elem.getBoundingClientRect();
    myX = rect.left + ((typeof window.pageXOffset !== "undefined") ?
        window.pageXOffset : document.body.scrollLeft);
    myY = rect.top + ((typeof window.pageYOffset !== "undefined") ?
        window.pageYOffset : document.body.scrollTop);
  } else {
    // this fall back doesn't properly handle absolutely positioned elements
    // inside a scrollable box
    var node;
    if (elem.offsetParent) {
      // subtract all scrolling
      node = elem;
      do {
        myX -= node.scrollLeft ? node.scrollLeft : 0;
        myY -= node.scrollTop ? node.scrollTop : 0;
      } while (node = node.parentNode);
      // this will include the page scrolling (which is unwanted) so add it back on
      myX += (typeof window.pageXOffset !== "undefined") ? window.pageXOffset : document.body.scrollLeft;
      myY += (typeof window.pageYOffset !== "undefined") ? window.pageYOffset : document.body.scrollTop;
      // sum up offsets
      node = elem;
      do {
        myX += node.offsetLeft;
        myY += node.offsetTop;
      } while (node = node.offsetParent);
    }
  }
  return [myX, myY];
}

/*
 * position_popup
 *
 * Positions a popup relative to an anchor element.
 *
 * The available positions are:
 * 0 - Centered below the anchor.
 */
function position_popup(anchor, popup, position) {
  "use strict";
  var a_x, a_y, a_w, a_h, p_x, p_y, p_w, p_h;
  var a_xy, spacer, margin, scrollbar, page_w;
  // define constants
  spacer = 5;
  margin = 15;
  scrollbar = 15;
  // define the positions and widths
  a_xy = coords(anchor);
  a_x = a_xy[0];
  a_y = a_xy[1];
  a_w = anchor.offsetWidth;
  a_h = anchor.offsetHeight;
  p_w = popup.offsetWidth;
  p_h = popup.offsetHeight;
  page_w = null;
  if (window.innerWidth) {
    page_w = window.innerWidth;
  } else if (document.body) {
    page_w = document.body.clientWidth;
  }
  // check the position type is defined
  if (typeof position !== "number") {
    position = 0;
  }
  // calculate the popup position
  switch (position) {
    case 1:
      p_x = a_x + a_w + spacer;
      p_y = a_y + (a_h / 2) - (p_h / 2);
      break;
    case 0:
    default:
      p_x = a_x + (a_w / 2) - (p_w / 2);
      p_y = a_y + a_h + spacer;
      break;
  }
  // constrain the popup position
  if (p_x < margin) {
    p_x = margin;
  } else if (page_w != null && (p_x + p_w) > (page_w - margin - scrollbar)) {
    p_x = page_w - margin - scrollbar - p_w;
  }
  if (p_y < margin) {
    p_y = margin;
  }
  // position the popup
  popup.style.left = p_x + "px";
  popup.style.top = p_y + "px";
}

function lookup_help_popup(popup_id) {
  var _body, pop, info;
  pop = document.getElementById(popup_id);
  if (pop == null) {
    _body = document.getElementsByTagName("body")[0];
    pop = document.createElement("div");
    pop.className = "pop_content";
    pop.id = popup_id;
    pop.style.backgroundColor = "#FFC";
    pop.style.borderColor = "black";
    info = document.createElement("p");
    info.style.fontWeight = "bold";
    info.appendChild(document.createTextNode("Error: No popup for topic \"" + popup_id + "\"."));
    pop.appendChild(info);
    // this might cause problems with the menu, but as this only happens
    // when something is already wrong I don't think that's too much of a problem
    _body.insertBefore(pop, _body.firstChild);
  }
  if (document.getElementsByTagName('body')[0].hasAttribute("data-autobtns")) {
    if (!/\bauto_buttons\b/.test(pop.className)) {
      pop.className += " auto_buttons";
      var back_btn_sec = document.createElement("div");
      back_btn_sec.className = "nested_only pop_back_sec";
      var back_btn = document.createElement("span");
      back_btn.className = "pop_back";
      back_btn.appendChild(document.createTextNode("<< back"));
      back_btn.addEventListener("click", function(e) {
        help_return();
      }, false);
      back_btn_sec.appendChild(back_btn);
      pop.insertBefore(back_btn_sec, pop.firstChild);
      var close_btn_sec = document.createElement("div");
      close_btn_sec.className = "pop_close_sec";
      var close_btn = document.createElement("span");
      close_btn.className = "pop_close";
      close_btn.appendChild(document.createTextNode("close"));
      close_btn.addEventListener("click", function(e) {
        help_popup();
      }, false);
      close_btn_sec.appendChild(close_btn);
      pop.appendChild(close_btn_sec);
    }
  }
  return pop;
}

/*
 * help_popup
 *
 * Moves around help pop-ups so they appear
 * below an activator.
 */
function help_popup(activator, popup_id) {
  "use strict";
  var pop;
  // set default values
  if (typeof help_popup.popup === "undefined") {
    help_popup.popup = [];
  }
  if (typeof help_popup.activator === "undefined") {
    help_popup.activator = null;
  }
  var last_pop = (help_popup.popup.length > 0 ? help_popup.popup[help_popup.popup.length - 1] : null);
  if (typeof(activator) == "undefined") { // no activator so hide
    if (last_pop != null) {
      last_pop.style.display = 'none';
      help_popup.popup = [];
    }
    return;
  }
  pop = lookup_help_popup(popup_id);
  if (pop == last_pop) {
    if (activator == help_popup.activator) {
      //hide popup (as we've already shown it for the current help button)
      last_pop.style.display = 'none';
      help_popup.popup = [];
      return; // toggling complete!
    }
  } else if (last_pop != null) {
    //activating different popup so hide current one
    last_pop.style.display = 'none';
  }
  help_popup.popup = [pop];
  help_popup.activator = activator;
  toggle_class(pop, "nested", false);
  //must make the popup visible to measure it or it has zero width
  pop.style.display = 'block';
  position_popup(activator, pop);
}

/*
 * help_refine
 * 
 * Intended for links within a help popup. Stores a stack of state so
 * you can go back.
 */
function help_refine(popup_id) {
  if (help_popup.popup == null || help_popup.popup.length == 0 || help_popup.activator == null) {
    //throw new Error("Cannot refine a help popup when one is not shown!");
    var pop = lookup_help_popup(popup_id);
    var act_id = popup_id + '_act';
    var activator = document.getElementById(act_id);
    help_popup(activator, popup_id);
  }
  var pop = lookup_help_popup(popup_id);
  var last_pop = help_popup.popup[help_popup.popup.length - 1];
  if (pop == last_pop) return; // slightly odd, but no real cause for alarm
  help_popup.popup.push(pop);
  toggle_class(pop, "nested", true);
  last_pop.style.display = "none";
  //must make the popup visible to measure it or it has zero width
  pop.style.display = "block";
  position_popup(help_popup.activator, pop);
}

/*
 * help_return
 * 
 * Intended for links within a help popup. Stores a stack of state so
 * you can go back.
 */
function help_return() {
  if (help_popup.popup == null || help_popup.popup.length == 0 || help_popup.activator == null) {
    throw new Error("Can not return to a earlier help popup when one is not shown!");
  }
  var last_pop = help_popup.popup.pop();
  last_pop.style.display = "none";
  var pop = (help_popup.popup.length > 0 ? help_popup.popup[help_popup.popup.length - 1] : null);
  if (pop != null) {
    toggle_class(pop, "nested", help_popup.popup.length > 1);
    pop.style.display = "block";
    position_popup(help_popup.activator, pop);
  } else {
    help_popup.activator = null;
  }
}

/*
 * update_scroll_pad
 *
 * Creates padding at the bottom of the page to allow
 * scrolling of anything into view.
 */
function update_scroll_pad() {
  var page, pad;
  page = (document.compatMode === "CSS1Compat") ? document.documentElement : document.body;
  pad = $("scrollpad");
  if (pad === null) {
    pad = document.createElement("div");
    pad.id = 'scrollpad';
    document.getElementsByTagName('body')[0].appendChild(pad);
  }
  pad.style.height = Math.abs(page.clientHeight - 100) + "px";
}

function substitute_classes(node, remove, add) {
  "use strict";
  var list, all, i, cls, classes;
  list = node.className.split(/\s+/);
  all = {};
  for (i = 0; i < list.length; i++) {
    if (list[i].length > 0) all[list[i]] = true;
  }
  for (i = 0; i < remove.length; i++) {
    if (all.hasOwnProperty(remove[i])) {
      delete all[remove[i]];
    }
  }
  for (i = 0; i < add.length; i++) {
    all[add[i]] = true;
  }
  classes = "";
  for (cls in all) {
    classes += cls + " ";
  }
  node.className = classes;
}

/*
 * toggle_class
 *
 * Adds or removes a class from the node. If the parameter 'enabled' is not 
 * passed then the existence of the class will be toggled, otherwise it will be
 * included if enabled is true.
 */
function toggle_class(node, cls, enabled) {
  var classes = node.className;
  var list = classes.replace(/^\s+/, '').replace(/\s+$/, '').split(/\s+/);
  var found = false;
  for (var i = 0; i < list.length; i++) {
    if (list[i] == cls) {
      list.splice(i, 1);
      i--;
      found = true;
    }
  }
  if (typeof enabled == "undefined") {
    if (!found) list.push(cls);
  } else {
    if (enabled) list.push(cls);
  }
  node.className = list.join(" ");
}

/*
 * find_child
 *
 * Searches child nodes in depth first order and returns the first it finds
 * with the className specified.
 * TODO replace with querySelector
 */
function find_child(node, className) {
  var pattern;
  if (node == null || typeof node !== "object") {
    return null;
  }
  if (typeof className === "string") {
    pattern = new RegExp("\\b" + className + "\\b");
  } else {
    pattern = className;
  }
  if (node.nodeType == Node.ELEMENT_NODE && 
      pattern.test(node.className)) {
    return node;
  } else {
    var result = null;
    for (var i = 0; i < node.childNodes.length; i++) {
      result = find_child(node.childNodes[i], pattern);
      if (result != null) break;
    }
    return result;
  }
}

/*
 * find_parent
 *
 * Searches parent nodes outwards from the node and returns the first it finds
 * with the className specified.
 */
function find_parent(node, className) {
  var pattern;
  pattern = new RegExp("\\b" + className + "\\b");
  do {
    if (node.nodeType == Node.ELEMENT_NODE && 
        pattern.test(node.className)) {
      return node;
    }
  } while (node = node.parentNode);
  return null;
}

/*
 * find_parent_tag
 *
 * Searches parent nodes outwards from the node and returns the first it finds
 * with the tag name specified. HTML tags should be specified in upper case.
 */
function find_parent_tag(node, tag_name) {
  do {
    if (node.nodeType == Node.ELEMENT_NODE && node.tagName == tag_name) {
      return node;
    }
  } while (node = node.parentNode);
  return null;
}

/*
 * __toggle_help
 *
 * Uses the 'topic' property of the this object to
 * toggle display of a help topic.
 *
 * This function is not intended to be called directly.
 */
function __toggle_help(e) {
  if (!e) e = window.event;
  if (e.type === "keydown") {
    if (e.keyCode !== 13 && e.keyCode !== 32) {
      return;
    }
    // stop a submit or something like that
    e.preventDefault();
  }

  help_popup(this, this.getAttribute("data-topic"));
}

function setup_help_button(button) {
  "use strict";
  var topic;
  if (button.hasAttribute("data-topic")) {
    topic = button.getAttribute("data-topic");
    if (document.getElementById(topic) != null) {
      button.tabIndex = "0"; // make keyboard selectable
      button.addEventListener("click", function() {
        help_popup(button, topic);
      }, false);
      button.addEventListener("keydown", function(e) {
        // toggle only on Enter or Spacebar, let other keys do their thing
        if (e.keyCode !== 13 && e.keyCode !== 32) return;
        // stop a submit or something like that
        e.preventDefault();
        help_popup(button, topic);
      }, false);
    } else {
      button.style.visibility = "hidden";
    }
  }
  button.className += " active";
}

/*
 * help_button
 *
 * Makes a help button for the passed topic.
 */
function help_button(topic) {
  var btn = document.createElement("div");
  btn.className = "help";
  btn.setAttribute("data-topic", topic);
  setup_help_button(btn);
  return btn;
}

/*
 * prepare_download
 *
 * Sets the attributes of a link to setup a file download using the given content.
 * If no link is provided then create one and click it.
 */
function prepare_download(content, mimetype, filename, link) {
  "use strict";
  // if no link is provided then create one and click it
  var click_link = false;
  if (!link) {
    link = document.createElement("a");
    click_link = true;
  }
  try {
    // Use a BLOB to convert the text into a data URL.
    // We could do this manually with a base 64 conversion.
    // This will only be supported on modern browsers,
    // hence the try block.
    var blob = new Blob([content], {type: mimetype});
    var reader = new FileReader();
    reader.onloadend = function() {
      // If we're lucky the browser will also support the download
      // attribute which will let us suggest a file name to save the link.
      // Otherwise it is likely that the filename will be unintelligible. 
      link.setAttribute("download", filename);
      link.href = reader.result;
      if (click_link) {
        // must add the link to click it
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
      }
    }
    reader.readAsDataURL(blob);
  } catch (error) {
    if (console && console.log) console.log(error);
    // probably an old browser
    link.href = "";
    link.visible = false;
  }
}

/*
 * add_cell
 *
 * Add a cell to the table row.
 */
function add_cell(row, node, cls, click_action) {
  var cell = row.insertCell(row.cells.length);
  if (node) cell.appendChild(node);
  if (cls && cls !== "") cell.className = cls;
  if (click_action) cell.addEventListener("click", click_action, false);
}

/*
 * add_header_cell
 *
 * Add a header cell to the table row.
 */
function add_header_cell(row, node, help_topic, cls, colspan) {
  var th = document.createElement("th");
  if (node) th.appendChild(node);
  if (help_topic && help_topic !== "") th.appendChild(help_button(help_topic));
  if (cls && cls !== "") th.className = cls;
  if (typeof colspan == "number" && colspan > 1) th.colSpan = colspan;
  row.appendChild(th);
}

/*
 * add_text_cell
 *
 * Add a text cell to the table row.
 */
function add_text_cell(row, text, cls, action) {
  var node = null;
  if (typeof(text) != 'undefined') node = document.createTextNode(text);
  add_cell(row, node, cls, action);
}

/*
 * add_text_header_cell
 *
 * Add a text header cell to the table row.
 */
function add_text_header_cell(row, text, help_topic, cls, action, colspan) {
  var node = null;
  if (typeof(text) != 'undefined') {
    var nbsp = (help_topic ? "\u00A0" : "");
    var str = "" + text;
    var parts = str.split(/\n/);
    if (parts.length === 1) {
      if (action) {
        node = document.createElement("span");
        node.appendChild(document.createTextNode(str + nbsp));
      } else {
        node = document.createTextNode(str + nbsp);
      }
    } else {
      node = document.createElement("span");
      for (var i = 0; i < parts.length; i++) {
        if (i !== 0) {
          node.appendChild(document.createElement("br"));
        }
        node.appendChild(document.createTextNode(parts[i]));
      }
    }
    if (action) {
      node.addEventListener("click", action, false);
      node.style.cursor = "pointer";
    }
  }
  add_header_cell(row, node, help_topic, cls, colspan);
}

function setup_help() {
  "use strict";
  var help_buttons, i;
  help_buttons = document.querySelectorAll(".help:not(.active)");
  for (i = 0; i < help_buttons.length; i++) {
    setup_help_button(help_buttons[i]);
  }
}

function setup_scrollpad() {
  "use strict";
  if (document.getElementsByTagName('body')[0].hasAttribute("data-scrollpad") && document.getElementById("scrollpad") == null) {
    window.addEventListener("resize", update_scroll_pad, false);
    update_scroll_pad();
  }
}

// anon function to avoid polluting global scope
(function() {
  "use strict";
  window.addEventListener("load", function load(evt) {
    window.removeEventListener("load", load, false);
    setup_help();
    setup_scrollpad();
  }, false);
})();

/*
 *  make_link
 *
 *  Creates a text node and if a URL is specified it surrounds it with a link.
 *  If the URL doesn't begin with "http://" it automatically adds it, as
 *  relative links don't make much sense in this context.
 */
function make_link(text, url) {
  var textNode = null;
  var link = null;
  if (typeof text !== "undefined" && text !== null) textNode = document.createTextNode(text);
  if (typeof url === "string") {
    if (url.indexOf("//") == -1) {
      url = "http://" + url;
    }
    link = document.createElement('a');
    link.href = url;
    if (textNode) link.appendChild(textNode);
    return link;
  }
  return textNode;
}

//
// Function to create an HTML paragraph describing the 
// MEME Suite background model source.
//
function make_background_source(title, source, text) {
  var paraNode = document.createElement("P");
  var titleNode = document.createElement("B");
  var textNode1 = document.createTextNode("\u00A0\u00A0\u00A0\u00A0" + title + ": ");
  titleNode.appendChild(textNode1);
  var source_text = ((source == "--motif--") ? "the (first) motif file" : (source == "--nrdb--") ? "an old version of the NCBI non-redundant database" : (source == "--uniform--") ? "the uniform model" : (source == "--query--") ? "the query file" : (source == "--sequences--") ? "built from the (primary) sequences" : ("the file '" + source + "'"));
  if (text) { return source_text; }
  var textNode2 = document.createTextNode(source_text);
  paraNode.appendChild(titleNode);
  paraNode.appendChild(textNode2);
  return paraNode;
}

// Function to create a help button
function make_help_button(container, help_topic) {
  container.appendChild(help_button(help_topic));
}
</script>
    <script>
//
// simple-shared-doc.js
//
// Function to replace the innerHTML of element "id" with the HTML indicated by "doc_type".
// Easier to read and update than the more flexible approach in shared-doc.js. 
//
function print_doc(id, doc_type) {
  var html;
  switch (doc_type) {
    case 'motif-consensus':
      html = `
	<p id="consensus_doc"> 
	   A <b>consensus sequence</b> is constructed from each column in a
	   motif's frequency matrix using the <b>"50% rule"</b>
	   as follows:
	</p>
	<ol>
	  <li>The letter frequencies in the column are sorted in decreasing order.</li>
	  <li>Letters with frequency less 50% of the maximum are discarded.</li>
	  <li>The letter used in this position in the consensus sequence is determined
	  by the first rule below that applies:</li>
	  <ul>
	    <li>If there is only one letter left, or if the remaining letters exactly match
	    an ambiguous symbol in the alphabet, the <b>letter</b> or <b>ambiguous symbol</b>,
	    respectively, is used.</li>
	    <li>Otherwise, if the remaining set contains at least 50% of the core
	    symbols in the alphabet, the alphabet's <b>wildcard</b>
	    (e.g., "N" for DNA or RNA, and "X" for protein) is used.</li>
	    <li>Otherwise, the letter with the <b>maximum frequency</b> is used.</li>
	  </ul>
	</ol>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'ame-results-header':
      html = `
	<p>
          AME outputs a tab-separated values (TSV) file ('ame.tsv') that contains one line for each motif
	  found to be significantly enriched.
	  The lines are sorted in order of decreasing statistical significance.
          The first line contains the (tab-separated) names of the fields.
	  Your command line is given at the end of the file in a comment line starting with the
	  character '#'.
	</p>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'ame-results-table':
      html = `
	<p>
	  The <a href="` + site_url + `/doc/ame-output-format.html#tsv_results">AME Results TSV Format</a> 
	  differs depending on the choice of method for measuring motif enrichment, as shown in the following table. 
	</p>
	<table style="width:100%" border=1>
	  <tr>
	    <th>Method</th>
	    <th colspan=19>Output Columns</th>
	  </tr>
	  <tr>
	    <th></th> 
	    <th>1</th>
	    <th>2</th>
	    <th>3</th>
	    <th>4</th>
	    <th>5</th>
	    <th>6</th>
	    <th>7</th>
	    <th>8</th>
	    <th>9</th>
	    <th>10</th>
	    <th>11</th>
	    <th>12</th>
	    <th>13 </th>
	    <th>14 </th>
	    <th>15 </th>
	    <th>16 </th>
	    <th>17 </th>
	    <th>18 </th>
	    <th>19 </th>
	  </tr>
	  <tr>
	    <td>fisher</td>
	    <td>rank </td>
	    <td>motif_DB </td>
	    <td>motif_ID </td>
	    <td>motif_alt_ID </td>
	    <td>consensus </td>
	    <td>p-value </td>
	    <td>adj_p-value </td>
	    <td>E-value</td>
	    <td>tests </td>
	    <td>FASTA_max </td>
	    <td>pos </td>
	    <td>neg </td>
	    <td>PWM_min</td>
	    <td>TP </td>
	    <td>%TP </td>
	    <td>FP </td>
	    <td>%FP </td>
	    </td> <td>
	    </td> <td>
	  </tr>
	  <tr>
	    <td>ranksum</td>
	    <td>rank </td>
	    <td>motif_DB </td>
	    <td>motif_ID </td>
	    <td>motif_alt_ID </td>
	    <td>consensus </td>
	    <td>p-value </td>
	    <td>adj_p-value </td>
	    <td>E-value</td>
	    <td>tests </td>
	    <td>FASTA_max </td>
	    <td>pos </td>
	    <td>neg</td>
	    <td>U </td>
	    <td>pleft </td>
	    <td>pright </td>
	    <td>pboth </td>
	    <td>adj_pleft </td>
	    <td>adj_pright </td>
	    <td>adj_both</td>
	  </tr>
	  <tr>
	    <td>3dmhg</td>
	    <td>rank </td>
	    <td>motif_DB </td>
	    <td>motif_ID </td>
	    <td>motif_alt_ID </td>
	    <td>consensus </td>
	    <td>p-value </td>
	    <td>adj_p-value </td>
	    <td>E-value</td>
	    <td>tests </td>
	    <td>FASTA_max </td>
	    <td>pos </td>
	    <td>neg</td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	  </tr>
	  <tr>
	    <td>4dmhg</td>
	    <td>rank </td>
	    <td>motif_DB </td>
	    <td>motif_ID </td>
	    <td>motif_alt_ID </td>
	    <td>consensus </td>
	    <td>p-value </td>
	    <td>adj_p-value </td>
	    <td>E-value</td>
	    <td>tests </td>
	    <td>FASTA_max </td>
	    <td>pos </td>
	    <td>neg</td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	  </tr>
	  <tr>
	    <td>pearson</td>
	    <td>rank </td>
	    <td>motif_DB </td>
	    <td>motif_ID </td>
	    <td>motif_alt_ID </td>
	    <td>consensus </td>
	    <td>p-value </td>
	    <td>adj_p-value </td>
	    <td>E-value</td>
	    <td>tests </td>
	    <td>Pearson_CC </td>
	    <td>mean_squared_error </td>
	    <td>slope </td>
	    <td>intercept</td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	  </tr>
	  <tr>
	    <td>spearman</td>
	    <td>rank </td>
	    <td>motif_DB </td>
	    <td>motif_ID </td>
	    <td>motif_alt_ID </td>
	    <td>consensus </td>
	    <td>p-value </td>
	    <td>adj_p-value </td>
	    <td>E-value</td>
	    <td>tests </td>
	    <td>Spearman_CC</td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	    </td> <td>
	  </tr>
        </table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'ame-results-description':
      html = `
        <p>
          The names and meanings of each of the fields in <a href="` + site_url + `/doc/ame-output-format.html#tsv_results">AME Results TSV Format</a>,
          which depend on the method of enrichment analysis you chose, are described below.
        </p>
        <table class="dark" style="width:100%" border=1>
	  <tr> <th>method</th> <th>field</th> <th>name</th> <th>contents</th> </tr>	
    	  <tr> <td>all</td> <td>1</td> <td>rank</td> <td>The rank of the significance of the motif in the sorted results.</td> </tr>
    	  <tr> <td>all</td> <td>2</td> <td>motif_DB</td> <td> ` + get_doc_text('motif-db', 'the motif.') + `</td> </tr>
    	  <tr> <td>all</td> <td>3</td> <td>motif_ID</td> <td> ` + get_doc_text('motif-id') + `</td> </tr>
    	  <tr> <td>all</td> <td>4</td> <td>motif_alt_ID</td> <td> ` + get_doc_text('motif-alt-id') + `</td> </tr>
    	  <tr> <td>all</td> <td>5</td> <td>consensus</td> <td> ` + get_doc_text('motif-cons') + `</td> </tr>
    	  <tr> <td>all</td> <td>6</td> <td>p-value</td> <td> ` + get_doc_text('ame-pvalue') + `</td> </tr>
    	  <tr> <td>all</td> <td>7</td> <td>adj_p-value</td> <td> ` + get_doc_text('ame-adj-pvalue') + `</td> </tr>
    	  <tr> <td>all</td> <td>8</td> <td>E-value</td> <td> ` + get_doc_text('ame-evalue') + `</td> </tr>
    	  <tr> <td>all</td> <td>9</td> <td>tests</td> <td>The number of tests performed; used in correcting the <i>p</i>-value</td> </tr>
	  <tr> <td colspan=4></td>
          <tr> <td>fisher, ranksum, 3dmhg, 4dmhg</td> <td>10</td> <td>FASTA_max</td> <td>The optimal threshold for <b>labeling</b> sequences as positive;
            sequences with FASTA score less than or equal to the threshold are labeled as positive;
            this field will be contain the number of primary sequences if you provided
            a control file (using option <code>--control</code>); this field will contain the size of the
            partition if you specified one (using option <code>--fix-partition</code>).</td> </tr>
          <tr> <td>fisher, ranksum, 3dmhg, 4dmhg</td> <td>11</td> <td>pos</td> <td>The number of sequences <b>labeled</b> as positive.</td> </tr>
          <tr> <td>fisher, ranksum, 3dmhg, 4dmhg</td> <td>12</td> <td>neg</td> <td>The number of sequences <b>labeled</b> as negative.</td> </tr>
	  <tr> <td colspan=4></td>
          <tr> <td>fisher</td> <td>13</td> <td>PWM_min</td> <td>The optimal threshold on PWM score for <b>classifying</b> sequences as positive;
                sequences with PWM score greater than or equal to the threshold are classified as positive.</td> </tr>
          <tr> <td>fisher</td> <td>14</td> <td>TP</td> <td>The number of true positive sequences: sequences both <b>labeled</b> and <b>classified</b> as positive</td> </tr>
          <tr> <td>fisher</td> <td>15</td> <td>%TP</td> <td>The percentage of true positive sequences: percentage of sequences <b>labeled</b> positive and <b>classified</b> as positive.</td> </tr>
          <tr> <td>fisher</td> <td>16</td> <td>FP</td> <td>The number of false positive sequences: sequences <b>labeled</b> negative but <b>classified</b> as positive.</td> </tr>
          <tr> <td>fisher</td> <td>17</td> <td>%TP</td> <td>The percentage of false positive sequences: sequences <b>labeled</b> negative but <b>classified</b> as positive.</td> </tr>
	  <tr> <td colspan=4></td>
          <tr> <td>ranksum</td> <td>13</td> <td>U</td> <td>The value of the Mann-Whitney <i>U</i> statistic.</td> </tr>
          <tr> <td>ranksum</td> <td>14</td> <td>pleft</td> <td>The left-tailed <i>p</i>-value of the rank-sum test.</td> </tr>
          <tr> <td>ranksum</td> <td>15</td> <td>pright</td> <td>The right-tailed <i>p</i>-value of the rank-sum test.</td> </tr>
          <tr> <td>ranksum</td> <td>16</td> <td>pboth</td> <td>The two-tailed <i>p</i>-value of the rank-sum test.</td> </tr>
          <tr> <td>ranksum</td> <td>17</td> <td>adj_pleft</td> <td>The left-tailed <i>p</i>-value of the rank-sum test, adjusted for multiple tests.</td> </tr>
          <tr> <td>ranksum</td> <td>18</td> <td>adj_pright</td> <td>The right-tailed <i>p</i>-value of the rank-sum test, adjusted for multiple tests.</td> </tr>
          <tr> <td>ranksum</td> <td>19</td> <td>adj_both</td> <td>The two-tailed <i>p</i>-value of the rank-sum test, adjusted for multiple tests.</td> </tr>
	  <tr> <td colspan=4></td>
	  <tr> <td>pearson</td> <td>10</td> <td>Pearson_CC</td> <td>The correlation coefficient of the PWM and FASTA scores of positive sequences.</td> </tr>
	  <tr> <td>pearson</td> <td>11</td> <td>mean_squared_error</td> <td>The mean-squared error of the regression line between PWM and FASTA scores.</td> </tr>
	  <tr> <td>pearson</td> <td>12</td> <td>slope</td> <td>The slope of the regression line.</td> </tr>
	  <tr> <td>pearson</td> <td>13</td> <td>intercept</td> <td>The y-intercept of the regression line.</td> </tr>
	  <tr> <td colspan=4></td>
	  <tr> <td>spearman</td> <td>10</td> <td>Spearman_CC</td> <td>The correlation coefficient of the PWM and FASTA ranks of positive sequences./td> </tr>
        </table>
	  </ul>
	</p>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'ame-sequences-tsv':
      html = `
        <p>AME outputs a tab-separated values (TSV) file ('sequences.tsv') containing one line for
	each sequence classified as 'positive' by AME for each significant motif.
        The first line contains the (tab-separated) names of the fields.
	The lines are grouped by motif, and groups are separated by a line
	starting with the character "#".
        </p>
        <p>
          The names and meanings of each of the fields in <a href="` + site_url + `/doc/ame-output-format.html#tsv_sequences">AME Significant Sequences TSV Format</a>,
          are described below.
        </p>
        <table class="dark" style="width:100%" border=1>
          <tr> <th>field</th> <th>name</th> <th>contents</th> </tr>
	  <tr> <td>1</td> <td>motif_DB</td> <td>` + get_doc_text('motif-db', 'the motif.') + `</td> </tr>
	  <tr> <td>2</td> <td>motif_ID</td> <td>the ID of the motif</td> </tr>
	  <tr> <td>3</td> <td>seq_ID</td> <td>the ID of the sequence</td> </tr>
	  <tr> <td>4</td> <td><i>label_score</i> (either FASTA_score or PWM_score)</td> <td>the value of the score used to label it as positive</td> </tr>
	  <tr> <td>5</td> <td><i>class_score</i> (either PWM_score or FASTA_score)</td> <td>the value of the score used to classify it as positive</td> </tr>
	  <tr> <td>6</td> <td>class</td> <td>whether the sequence is a true positive, 'tp', or a false positive, 'fp'</td> </tr>
        </table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'centrimo-results-tsv':
      html = `
	<p>
          CentriMo outputs a tab-separated values (TSV) file ('centrimo.tsv') that contains one line for each 
	  region found to be significantly enriched for a motif.
	  The lines are sorted in order of decreasing statistical significance.
          The first line contains the (tab-separated) names of the fields.
          Your command line is given at the end of the file in a comment line starting with the
          character '#'.
	</p>
	<p>
          The names and meanings of each of the fields in <a href="` + site_url + `/doc/centrimo-output-format.html#tsv_results">CentriMo Results TSV Format</a>,
          which depend on whether or not you provide control sequences to CentriMo, are described below.
	</p>
        <table class="dark" style="width:100%" border=1>
          <tr> <th>field</th> <th>name</th> <th>contents</th> </tr>
	  <tr> <td>1</td> <td>db_index</td> <td>The index of the motif file that contains the motif.  Motif
	      files are numbered in the order the appeared in the command line.</td> </tr>
	  <tr> <td>2</td> <td>motif_id</td> <td> ` + get_doc_text('motif-id') + `
	      If more than one motif has the same ID, CentriMo uses only the first such motif.
	      The name is single-quoted and preceded with '+' or '-' if you scanned separately with 
	      the reverse complement motif (using the <code>--sep</code> option).</td> </tr>
	  <tr> <td>3</td> <td>motif_alt_id</td> <td> ` + get_doc_text('motif-alt-id') + `</td> </tr>
	  <tr> <td>4</td> <td>consensus</td> <td> ` + get_doc_text('motif-cons') + `</td> </tr>
	  <tr> <td>5</td> <td>E-value</td> <td> ` + get_doc_text('centrimo-evalue') + `</td> </tr>
	  <tr> <td>6</td> <td>adj_p-value</td> <td> ` + get_doc_text('centrimo-adj-pvalue') + `
	      By default, a <i>p</i>-value is calculated by using the one-tailed binomial
	      test on the number of sequences with a match to the motif
	      that have their best match in the reported region;
              if you provided control sequences, the <i>p</i>-value of Fisher\'s exact test on the enrichment of 
              best matches in the positive sequences relative to the negative sequences is computed instead;
	      if you used the <code>--cd</code> option, the <i>p</i>-value is the probability that the average 
	      distance between the best site and the sequence center would be as low or lower than observed, 
	      computed using the cumulative Bates distribution, optimized over different score thresholds.
	      In all cases, the reported <i>p</i>-value has been adjusted for the number of regions
	      and/or score thresholds tested.</td> </tr>
	  <tr> <td>7</td> <td>log_adj_p-value</td> <td>Log of adjusted <i>p</i>-value.</td> </tr>
	  <tr> <td>8</td> <td>bin_location</td> <td>Location of the center of the most enriched region, or
		0 if you used the <code>--cd</code> option.
	  <tr> <td>9</td> <td>bin_width</td> <td> ` + get_doc_text('centrimo-bin-width') + `</td> </tr>
	  <tr> <td>10</td> <td>total_width</td> <td>The maximum number of regions possible for this motif
              <br>&nbsp;&nbsp;
	      round(sequence_length - motif_length + 1)/2,<br>
	      or the number of places the motif will fit if you used the <code>--cd</code> option.</td> </tr>
	  <tr> <td>11</td> <td>sites_in_bin</td> <td> ` + get_doc_text('centrimo-sites-in-bin') + `</td> </tr>
	  <tr> <td>12</td> <td>total_sites</td> <td>The number of sequences containing a match to the motif
	      above the score threshold.
	  <tr> <td>13</td> <td>p_success</td> <td>The probability of a random match falling into the enriched region:
	      <br>&nbsp;&nbsp;
	      bin_width / total_width</td> </tr>
	  <tr> <td>14</td> <td>p-value</td> <td>The uncorrected <i>p</i>-value before it gets adjusted for the
	      number of multiple tests to give the adjusted <i>p</i>-value.</td> </tr>
	  <tr> <td>15</td> <td>mult_tests</td> <td> ` + get_doc_text('centrimo-mult-tests') + `</td> </tr>
	  <tr> <th colspan=3>The following additional columns are present when you provide control sequences to CentriMo
	  (using the <code>--neg</code> option).</th> </tr>
	  <tr> <td>16</td> <td>neg_sites_in_bin</td> <td>The number of negative sequences where the best
	      match to the motif falls in the reported region.
	      This value is rounded but the underlying value may contain fractional counts.
	      Note: This number may be less than the number of negative have a best match in the region.
	      The reason for this is that a sequence may have many matches that score equally best.
	      If n matches have the best score in a sequence, 1/n is added to the
	      appropriate bin for each match.</td> </tr>
	  <tr> <td>17</td> <td>neg_sites</td> <td>The number of negative sequences containing a match to the
	      motif above the minimum score threshold.
	      When score optimization is enabled the score threshold may be raised
	      higher than the minimum.</td> </tr>
	  <tr> <td>18</td> <td>neg_adj_pvalue</td> <td>The probability that any tested region in the negative
	      sequences would be as enriched for best matches to this motif
	      according to the Binomial test.</td> </tr>
	  <tr> <td>19</td> <td>log_neg_adj_pvalue</td> <td>Log of negative adjusted <i>p</i>-value.</td> </tr>
	  <tr> <td>20</td> <td>fisher_adj_pvalue</td> <td>Fisher adjusted <i>p</i>-value before it gets adjusted for the
	      number of motifs in the input files(s).</td> </tr>
	  <tr> <td>21</td> <td>log_fisher_adj_pvalue</td> <td>Log of Fisher adjusted <i>p</i>-value.</td> </tr>
        </table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'centrimo-sites-txt':
      html = `
	<p>
          CentriMo outputs a text file ('site_counts.txt') that contains,
	  for each motif, pairs of values (bin_position, site_count),
	  or triples of values (bin_position, site_count, neg_site_count) if
	  you provided control sequences to CentriMo.
	  This data can be used to plot the density of motif best matches (sites)
	  along the input sequences.  Fractional counts are possible if multiple (n)
	  bins contain the best match for a given sequence, with each bin  
	  receiving an incremental count of 1/n. 
	</p>
	<p>
	  The data for each motif begins with a header line with the format:
	  <br>&nbsp&nbsp
		DB &lt;db_number&gt; MOTIF &lt;id&gt; &lt;alt&gt;
	  </br>
	  where &lt;id&gt; and &lt;alt&gt; are as described above.
	  The following lines (up to the next header line) 
	  each contain a single value-pair or value-triple for the motif
	  named in the header line.
	</p>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'meme-chip-results-tsv':
      html = `
	<p>
          MEME-ChIP outputs a tab-separated values (TSV) file ('summary.tsv') that 
	  contains one line for each motif found by MEME-ChIP.
	  The lines are sorted in order of decreasing statistical significance.
	  The first line contains the (tab-separated) names of the fields.
	  Your command line is given at the end of the file in a comment line starting with the
	  character '#'.
	</p>
	<p>
          The names and meanings of the fields in the 
	  <a href="` + site_url + `/doc/meme-chip-output-format.html">MEME-ChIP Results Summary TSV Format</a> 
	  are described below. 
	</p>
        <table class="dark" style="width:100%" border=1>
          <tr> <th>field</th> <th>name</th> <th>contents</th> </tr>
          <tr> <td>1</td> <td>MOTIF_INDEX</td> <td>The index of the motif in the "Motifs in MEME text format" file ('combined.meme') 
		output by MEME-ChIP.</td> </tr>
          <tr> <td>2</td> <td>MOTIF_SOURCE</td> <td>The name of the program that found the <i>de novo</i> motif, or the
                name of the motif file containing the known motif.</td> </tr>
          <tr> <td>3</td> <td>MOTIF_ID</td> <td> ` + get_doc_text('motif-id') + `</td> </tr>
          <tr> <td>4</td> <td>ALT_ID</td> <td> ` + get_doc_text('motif-alt-id') + `</td> </tr>
          <tr> <td>5</td> <td>CONSENSUS</td> <td>The ID of the <i>de novo</i> motif, or a consensus sequence
                computed from the letter frequencies in the known motif
                (as described <a href="#consensus_doc">below</a>).</td> </tr>
          <tr> <td>6</td> <td>WIDTH</td> <td>The width of the motif.</td> </tr>
          <tr> <td>7</td> <td>SITES</td> <td>The number of sites reported by the <i>de novo</i> program, or the number
                of "Total Matches" reported by CentriMo.</td> </tr>
          <tr> <td>8</td> <td>E-VALUE</td> <td>The statistical significance of the motif.</td> </tr>
          <tr> <td>9</td> <td>E-VALUE_SOURCE</td> <td>The program that reported the <i>E</i>-value.</td> </tr>
          <tr> <td>10</td> <td>MOST_SIMILAR_MOTIF</td> <td>The known motif most similar to this motif according to Tomtom.</td> </tr>
          <tr> <td>11</td> <td>URL</td> <td>A link to a description of the most similar motif, or to the known motif.</td> </tr>
        </table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'meme-chip-combined-motifs':
      html = `
        <p>
          MEME-ChIP outputs a text file ('combined.meme') containing all the significant motifs found by MEME-ChIP.
          The motifs are in <a href="` + site_url + `/doc/meme-format.html">Minimal MEME Motif format</a>, 
	  and their IDs correspond to the motif indices given in the "Summary in TSV Format" file ('summary.tsv').
        </p>
        </p>
          <b>Note:</b> The 'nsites=' and 'E=' fields in the motif headers are only
          relevant for the MEME and DREME motifs.  For known motifs, those values do
          not refer to the number of sites in the input sequences.
        </p>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'spamo-results-tsv':
      html = `
	<p>
          SpaMo outputs a tab-separated values (TSV) file ('spamo.tsv') that contains one line for each motif
	  found to be significantly enriched.
	  The lines are grouped by secondary motif and sorted in order of decreasing statistical significance.
          The first line contains the (tab-separated) names of the fields.
	  Your command line is given at the end of the file in a comment line starting with the character '#'.
	</p>
	<p>
	  The names and meanings of each of the fields in <a href="` + site_url + `/doc/spamo-output-format.html#results-tsv">SpaMo Results TSV Format</a> 
	  are described below. 
	</p>
	<table class="dark" style="width:100%" border=1>
	  <tr> <th>field</th> <th>name</th> <th>contents</th> </tr>
          <tr> <td>1</td> <td>prim_db</td> <td> ` + get_doc_text('motif-db', 'the primary motif.') + `</td> </tr>
          <tr> <td>2</td> <td>prim_id</td> <td> ` + get_doc_text('motif-id', 'primary') + `</td> </tr>
          <tr> <td>3</td> <td>prim_alt</td> <td> ` + get_doc_text('motif-alt-id', 'primary') + `</td> </tr>
          <tr> <td>4</td> <td>prim_cons</td> <td> ` + get_doc_text('motif-cons', 'primary') + `</td> </tr>
          <tr> <td>5</td> <td>sec_db</td> <td> ` + get_doc_text('motif-db', 'the secondary motif.') + `</td> </tr>
          <tr> <td>6</td> <td>sec_id</td> <td> ` + get_doc_text('motif-id', 'secondary') + `</td> </tr>
          <tr> <td>7</td> <td>sec_alt</td> <td> ` + get_doc_text('motif-alt-id', 'secondary') + `</td> </tr>
          <tr> <td>8</td> <td>sec_cons</td> <td> ` + get_doc_text('motif-cons', 'secondary') + `</td> </tr>
          <tr> <td>9</td> <td>trim_left</td> <td>Number of positions trimmed from left of secondary motif.</td> </tr>
          <tr> <td>10</td> <td>trim_right</td> <td>Number of positions trimmed from right of secondary motif.</td> </tr> 
          <tr> <th colspan=3>If the next three fields are not blank, the motif is redundant with a more significant ('parent') motif.</th> </tr>
          <tr> <td>11</td> <td>red_db</td> <td> ` + get_doc_text('motif-db', 'the parent motif.') + `</td> </tr>
          <tr> <td>12</td> <td>red_id</td> <td> ` + get_doc_text('motif-id', 'parent') + `</td> </tr>
          <tr> <td>13</td> <td>red_alt</td> <td> ` + get_doc_text('motif-alt-id', 'parent') + `</td> </tr>
          <tr> <td>14</td> <td>E-value</td> <td>The expected number motifs that would have least one spacing as enriched as the best spacing for this secondary. 
	    The <i>E</i>-value is the best spacing <i>p</i>-value multiplied by the number of motifs in the input database(s).</td> </tr>
          <tr> <td>15</td> <td>gap</td> <td>The distance between the edge of the primary and the (trimmed) secondary motif.</td> </tr>
          <tr> <td>16</td> <td>orient</td> <td>The (combination) of quadrants for which occurrences of this spacing are combined.</td> </tr>
          <tr> <td>17</td> <td>count</td> <td>The number of occurrences of the secondary motif with the given spacing and orientation to the primary motif.</td> </tr>
          <tr> <td>18</td> <td>total</td> <td>The total number of occurrences of the secondary motif within the margins around the best primary motif occurrence.</td> </tr>
          <tr> <td>19</td> <td>adj_p-value</td> <td>The <i>p</i>-value of the gap and orientation, adjusted for nine combinations of quadrants times the number of gaps tested (as controlled by the <code>-range</code> option).</td> </tr>
          <tr> <td>20</td> <td>p-value</td> <td>The <i>p</i>-value of the gap and orientation adjusted only for the number of gaps tested.</td> </tr>
        </table>
        <br>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'spamo-dumpseqs-tsv':
      html = `
	<p>
	  By specifying the options <code>--dumpseqs</code> or <code>--dumpsigs</code> 
	  you can have SpaMo create TSV (tab-separated values) files
	  describing the motif matches SpaMo used to make the histograms in its HTML output.
	  The files are named 
          '<code>seqs_&lt;primary_motif&gt;_&lt;secondary_db&gt;_&lt;secondary_motif&gt;.txt</code>'.
	  The rows in each file are sorted by sequence name.  
	  The first line contains the (tab-separated) names of the fields.
        </p>
	<p>
	  The names and meanings of each of the fields in <a href="` + site_url + `/doc/spamo-output-format.html#tsv_dumpseqs">SpaMo Dumpseqs TSV Format</a> 
	  are described below. 
        </p>
	<table class="dark" style="width:100%">
	  <tr><th>field</th><th>name</th><th>contents</th></tr>
	  <tr><td>1</td><td>matches</td><td>Trimmed lowercase sequence centered on primary match with matches in uppercase.</td></tr>
	  <tr><td>2</td><td>sec_pos</td><td>Position of the secondary match within the whole sequence.</td></tr>
	  <tr><td>3</td><td>pri_match</td><td>Sequence fragment that the primary matched.</td></tr>
	  <tr><td>4</td><td>pri_strand</td><td>Strand of the primary match (+/-).</td></tr>
	  <tr><td>5</td><td>sec_match</td><td>Sequence fragment that the secondary matched.</td></tr>
	  <tr><td>6</td><td>sec_strand</td><td>Strand of the secondary match (+/-).</td></tr>
	  <tr><td>7</td><td>same_opp</td><td>The primary match on the same (s) or opposite (o) strand as the secondary.</td></tr>
	  <tr><td>8</td><td>down_up</td><td>The secondary match is downstream (d) or upstream (u) of the primary.</td></tr>
	  <tr><td>9</td><td>gap</td><td>The gap between the primary and secondary matches.</td></tr>
	  <tr><td>10</td><td>seq_name</td><td>The name of the sequence.</td></tr>
	  <tr><td>11</td><td>adj_p-value</td><td>The <i>p</i>-value of the bin containing the match, adjusted for the number of bins.</td></tr>
	  <tr><th colspan="3">If the sequence names are in UCSC Genome Browser position
	  format (e.g., "chr5:36715616-36715623"), the following additional fields will be present:</th></tr>
	  <tr><td>12</td><td>pri_bed_chr</td><td>Position of primary match in BED coordinates.</td></tr>
	  <tr><td>13</td><td>pri_bed_start</td><td>"</td></tr>
	  <tr><td>14</td><td>pri_bed_end</td><td>"</td></tr>
	  <tr><td>15</td><td>pri_browser</td><td>Position of primary match in UCSC Genome Browser coordinates.</td></tr>
	  <tr><td>16</td><td>sec_bed_chr</td><td>Position of secondary match in BED coordinates.</td></tr>
	  <tr><td>16</td><td>sec_bed_start</td><td>"</td></tr>
	  <tr><td>16</td><td>sec_bed_end</td><td>"</td></tr>
	  <tr><td>19</td><td>sec_browser</td><td>Position of secondary match in UCSC Genome Browser coordinates.</td></tr>
	</table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'fimo-results-tsv':
      html = ` 
        <p>
          FIMO outputs a tab-separated values (TSV) file ('fimo.tsv') that contains one line for each
          significant match to a motif.
          The lines are sorted in order of decreasing statistical significance (increasing <i>p</i>-value).
          The first line contains the (tab-separated) names of the fields.
          Your command line is given at the end of the file in a comment line starting with the
          character '#'.
        </p>
	<p>
	  The names and meanings of each of the fields in <a href="` + site_url + `/doc/fimo-output-format.html#results-tsv">FIMO Results TSV Format</a> 
	  are described below. 
	</p>
	<table class="dark" style="width:100%" border=1>
	  <tr> <th>field</th> <th>name</th> <th>contents</th> </tr>
          <tr> <td>1</td> <td>motif_id</td> <td> ` + get_doc_text('motif-id') + `</td> </tr>
          <tr> <td>2</td> <td>motif_alt_id</td> <td> ` + get_doc_text('motif-alt-id') + `</td> </tr>
          <tr> <td>3</td> <td>sequence_name</td> <td> ` + get_doc_text('sequence-id') + ` --OR-- the `
	    + get_doc_text('sequence-name') + `</td> </tr>
          <tr> <td>4</td> <td>start</td> <td> ` + get_doc_text('match-start-seq', 'motif occurrence') + ` --OR-- `
            + get_doc_text('match-start-genomic', 'motif occurrence') 
            + get_doc_text('parse-genomic-coord', 'The latter case occurs when FIMO') + `</td> </tr>
          <tr> <td>5</td> <td>stop</td> <td> ` + get_doc_text('match-stop-seq', 'motif occurrence') + ` --OR-- `
            + get_doc_text('match-stop-genomic', 'motif occurrence') 
            + get_doc_text('parse-genomic-coord', 'The latter case occurs when FIMO') + `</td> </tr>
          <tr> <td>6</td> <td>strand</td> <td>The strand '<code>+</code>' indicates the motif matched the forward
	    strand, '<code>-</code>' the reverse strand, and '<code>.</code>'
	    indicates strand is not applicable (as for amino acid sequences).</td> </tr>
          <tr> <td>7</td> <td>score</td> <td>The score for the motif occurrence. `
            + get_doc_text('motif-match-score') + `</td> </tr>
          <tr> <td>8</td> <td>p-value</td> <td> The <i>p</i>-value of the motif occurrence. `
            + get_doc_text('motif-match-p-value') + `</td> </tr>
          <tr> <td>9</td> <td>q-value</td> <td>The q-value of the motif occurrence. `
            + get_doc_text('bh-q-value', 'FIMO') + ` <b>Note:</b> This column is empty if you used the <span class=popt>--text</span> switch.</td> </tr>
          <tr> <td>10</td> <td>sequence</td> <td>The region of the sequence matched to the motif.</td> </tr>
        </table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'fimo-results-gff3':
      html = `
        <p>
          FIMO outputs a GFF3</a> file ('fimo.gff') that contains one line for each
          significant match to a motif.
        </p>
        <p>
	  The GFF3 format is described <a href="http://gmod.org/wiki/GFF3">here</a>.
	  The 'score' reported in the FIMO GFF3 output</a> (in column 6) is<br/>
	  &nbsp;&nbsp;&nbsp;&nbsp;<code>min(1000, -10*(log10(pvalue)))</code>, <br/>
	  and the 'display name' ('Name=' tag in column 9) is composed of the contents of three 
	  fields as follows <br/>
	  &nbsp;&nbsp;&nbsp;&nbsp;<code>&lt;motif_id&gt;_&lt;sequence_name&gt;&lt;strand&gt;</code>.
        </p>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'gomo-results-tsv':
      html = `
        <p>
          GOMo outputs a tab-separated values (TSV) file ('gomo.tsv') that contains one line for each 
	  motif-GO-term pair found to be significantly enriched.
          The lines are grouped by motif and sorted in order of decreasing statistical significance.
          The first line contains the (tab-separated) names of the fields.
          Your command line is given at the end of the file in a comment line starting with the character '#'.
        </p>
        <p>
          The names and meanings of each of the fields in <a href="` + site_url + `/doc/gomo-output-format.html#results-tsv">GOMo Results TSV Format</a>
          are described below.
        </p>
        <table class="dark" style="width:100%" border=1>
          <tr> <th>field</th> <th>name</th> <th>contents</th> </tr>
          <tr> <td>1</td> <td>Motif_Identifier</td> <td> ` + get_doc_text('motif-id') + ` </td> </tr> 
          <tr> <td>2</td> <td>GO_Term_Identifier</td> <td> ` + get_doc_text('gomo-go-term') + ` </td> </tr>
          <tr> <td>3</td> <td>GOMo_Score</td> <td> ` + get_doc_text('gomo-score') + ` </td> </tr>
          <tr> <td>4</td> <td>p-value</td> <td> ` + get_doc_text('gomo-p-value') + ` </td> </tr>
          <tr> <td>5</td> <td>q-value</td> <td> ` + get_doc_text('bh-q-value', 'GOMo') + ` </td> </tr>
        </table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'gomo-results-xml':
      html = `
	<p>
	GOMo outputs an XML file ('gomo.xml') with the following format.
	</p>
	<table class="bordertable" border="1">
	  <tr>
	    <th>Tag</th><th>Child of</th><th>Description</th>
	  </tr>
	  <tr>
	    <td >&lt;gomo&gt;</td><td >Nothing</td>
	    <td>
	      Information about this run of GOMo.
	      <ul>
		<li>version - The version of GOMo that generated the XML file.</li>
		<li>release - The release date of the version that generated the XML.</li>
	      </ul>
	    </td>
	  </tr>
	  <tr>
	    <td >&lt;program&gt;</td>
	    <td >&lt;gomo&gt;</td>
	    <td>
	      Information about the state of the program when it ran.<br />
	      <ul>
		<li>name - name of the program.</li>
		<li>cmd - the command line passed to the program.</li>
		<li>gene_url - the url used to lookup further information on the gene ids. 
		The url has ampersands (&amp;) converted into <b>&amp;amp;</b> and the place where
		  the gene ID should be replaced by <b>!!GENEID!!</b> .</li>
		<li>outdir - the output directory that the program wrote to.</li>
		<li>clobber - true if GOMo was allowed to overwrite the output directory.</li>
		<li>text_only - true if GOMo wrote to stdout, in which case this file would
		  not exist so it must be false.</li>
		<li>use_e_values - true if GOMo used <i>E</i>-values (converted from <i>p</i>-values) as 
		  input scores, false if GOMo used gene scores.</li>
		<li>score_e_thresh - if GOMo used <i>E</i>-values then this is the threshold that 
		  GOMo assumed the worst <i>E</i>-value (<i>p</i>-value = 1.0) for the gene to smooth out noise.</li>
		<li>min_gene_count - the minimum number of genes that a GO term was annotated 
		  with before GOMo would calculate a score for it.</li>
		<li>motifs - if present then a space delimited list of the motifs that GOMo
		  calculated a score for, otherwise GOMo scored all motifs.</li>
		<li>shuffle_scores - the number of times GOMo generated a shuffled mapping of
		  gene id to gene id to be used to generate scores from the null model.</li>
		<li>q_threshold - GOMo filtered the results to only show those with a better
		(smaller) q-value.</li>
	      </ul>
	    </td>
	  </tr>
	  <tr>
	    <td>&lt;gomapfile&gt;</td>
	    <td>&lt;program&gt;</td>
	    <td>
	      Information about the GO mapping file.<br />
	      <ul>
		<li>path - the path to the mapping file.</li>
	      </ul>
	    </td>
	  </tr>
	  <tr>
	    <td>&lt;seqscorefile&gt;</td>
	    <td>&lt;program&gt;</td>
	    <td>
	      Information about the sequence scoring file.<br />
	      <ul>
		<li>path - the path to the sequence scoring file.</li>
	      </ul>
	    </td>
	  </tr>
	  <tr>
	    <td>&lt;motif&gt;</td>
	    <td>&lt;gomo&gt;</td>
	    <td>
	      Information about the motif.<br />
	      <ul>
		<li>id - the motif identifier.</li>
		<li>genecount - the number of scored sequences that were used to compute the result.</li>
	      </ul>
	    </td>
	  </tr>
	  <tr>
	    <td>&lt;goterm&gt;</td>
	    <td>&lt;motif&gt;</td>
	    <td>
	      Information about the GO term.<br />
	      <ul>
		<li>id - the GO identifier.</li>
		<li>score - the geometric mean across all species of the rank-sum test <i>p</i>-value.</li>
		<li>pvalue - the empirically calculated <i>p</i>-value.</li>
		<li>qvalue - the empirically calculated q-value.</li>
		<li>annotated - the number of genes annotated with the go term.</li>
		<li>group - the subgroup that the term belongs to. For the Gene Ontology 
		    b = biological process, c = cellular component and m = molecular function.</li>
		<li>nabove - the number of more general terms that link to this one.</li>
		<li>nbelow - the number of more specific terms that link from this one.</li>
		<li>implied - is the go term implied by other significant go terms? 
		  Allows values 'y', 'n' or 'u' (default) for yes, no or unknown.</li>
		<li>description - the GO term description.</li>
	      </ul>
	    </td>
	  </tr>
	  <tr>
	    <td>&lt;gene&gt;</td>
	    <td>&lt;goterm&gt;</td>
	    <td>
	      Information about the GO term's annotated genes for the primary species.<br />
	      <ul>
		<li>id - the gene identifier.</li>
		<li>rank - the rank of the scored gene.</li>
	      </ul>
	    </td>
	  </tr>
        </table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'mcast-results-tsv':
      html = ` 
        <p>
          MCAST outputs a tab-separated values (TSV) file ('mcast.tsv') that contains one line for each
          significant match of a cluster of motifs to a sequence region.
          The lines are sorted in order of decreasing statistical significance (increasing <i>p</i>-value).
          The first line contains the (tab-separated) names of the fields.
          Your command line is given at the end of the file in a comment line starting with the
          character '#'.
        </p>
	<p>
	  The names and meanings of each of the fields in 
          <a href="` + site_url + `/doc/mcast-output-format.html#results-tsv">MCAST Results TSV Format</a> 
	  are described below. 
	</p>
	<table class="dark" style="width:100%" border=1>
	  <tr> <th>field</th> <th>name</th> <th>contents</th> </tr>
          <tr> <td>1</td> <td>pattern_name</td> <td>A unique name that MCAST generates for the match. </td> </tr>
          <tr> <td>2</td> <td>sequence_name</td> <td> ` + get_doc_text('sequence-id') + ` --OR-- the `
	    + get_doc_text('sequence-name') + `</td> </tr>
          <tr> <td>3</td> <td>start</td> <td> ` + get_doc_text('match-start-seq', 'matched sequence region') + ` --OR-- `
            + get_doc_text('match-start-genomic', 'motif occurrence')
            + get_doc_text('parse-genomic-coord', 'The latter case occurs when MCAST') + `</td> </tr>
          <tr> <td>4</td> <td>stop</td> <td> ` + get_doc_text('match-stop-seq', 'matched sequence region') + ` --OR-- `
            + get_doc_text('match-stop-genomic', 'motif occurrence')
            + get_doc_text('parse-genomic-coord', 'The latter case occurs when MCAST') + `</td> </tr>
          <tr> <td>5</td> <td>score</td> <td> ` + get_doc_text('mcast-cluster-score') + ` </td> </tr>
          <tr> <td>6</td> <td>p-value</td> <td> ` + get_doc_text('mcast-cluster-p-value') + ` </td> </tr>
          <tr> <td>7</td> <td>E-value</td> <td> ` + get_doc_text('mcast-cluster-E-value') + ` </td> </tr>
          <tr> <td>8</td> <td>q-value</td> <td> ` + get_doc_text('bh-q-value', 'MCAST') + ` 
	    <b>Note:</b> This column is empty if you used the <span class=popt>--text</span> switch.</td> </tr>
          <tr> <td>9</td> <td>sequence</td> <td>The region of the sequence matched to the motif cluster.</td> </tr>
        </table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'mcast-results-gff3':
      html = `
        <p>
          MCAST outputs a GFF3</a> file ('mcast.gff') that contains one line for each
          significant match to a motif cluster.
        </p>
        <p>
	  The GFF3 format is described <a href="http://gmod.org/wiki/GFF3">here</a>.
	  The 'score' reported in the MCAST GFF3 output</a> (in column 6) is<br/>
	  &nbsp;&nbsp;&nbsp;&nbsp;<code>min(1000, -10*(log10(pvalue)))</code>, <br/>
	  and the 'unique identifier' ('ID=' tag in column 9) is the value of the
	  &lt;pattern_name&gt; field in the MCAST results TSV format.  Following the
	  unique identifier in column 9, the <i>p</i>-value, <i>E</i>-value and q-value
	  of the match are given.
        </p>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    case 'tomtom-results-tsv':
      html = `
	<p>
          Tomtom outputs a tab-separated values (TSV) file ('tomtom.tsv') that contains one line for each motif
	  found to be significantly enriched.
	  The lines are grouped by query motif and sorted in order of decreasing statistical significance.
          The first line contains the (tab-separated) names of the fields.
	  Your command line is given at the end of the file in a comment line starting with the character '#'.
	</p>
	<p>
	  The names and meanings of each of the fields in <a href="` + site_url + `/doc/tomtom-output-format.html#results-tsv">Tomtom Results TSV Format</a> 
	  are described below. 
	</p>
	<table class="dark" style="width:100%" border=1>
	  <tr> <th>field</th> <th>name</th> <th>contents</th> </tr>
          <tr> <td>1</td> <td>Query_ID</td> <td> ` + get_doc_text('motif-id', 'query') + `</td> </tr>
          <tr> <td>2</td> <td>Target_ID</td> <td> ` + get_doc_text('motif-id', 'target') + `</td> </tr>
          <tr> <td>3</td> <td>Optimal_offset</td> <td> ` + get_doc_text('tomtom-offset') + `</td> </tr>
          <tr> <td>4</td> <td>p-value</td> <td> ` + get_doc_text('tomtom-p-value') + `</td> </tr>
          <tr> <td>5</td> <td>E-value</td> <td> ` + get_doc_text('tomtom-E-value') + `</td> </tr>
          <tr> <td>6</td> <td>q-value</td> <td> ` + get_doc_text('bh-q-value', 'Tomtom') + `</td> </tr>
          <tr> <td>7</td> <td>Overlap</td> <td> ` + get_doc_text('tomtom-overlap') + `</td> </tr>
          <tr> <td>8</td> <td>Query_consensus</td> <td>A consensus sequence
                computed from the letter frequencies in the query motif
                (as described <a href="#consensus_doc">below</a>).</td> </tr>
          <tr> <td>9</td> <td>Target_consensus</td> <td>A consensus sequence
                computed from the letter frequencies in the target motif
                (as described <a href="#consensus_doc">below</a>).</td> </tr>
          <tr> <td>10</td> <td>Orientation</td> <td> ` + get_doc_text('tomtom-orientation', "<br>A value of '+' means that the target motif is as it appears in the database. A value of '-' means that the reverse complement of the target motif is shown.") + `</td> </tr>
        </table>
      `;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
      break;

    default:
      html = "Error--Unrecognized doc_type: " + doc_type;
      document.getElementById(id).insertAdjacentHTML('beforeend', html);
  }
} // print_doc

//
// Function to return the HTML text of a given type.
// This function can be used directly to document the output format (xx-output-format.html)
// and indirectly via print_doc_para for help pop-ups in the actual output HTML,
// to prevent duplication of documentation.
//
function get_doc_text(doc_type, extra) {
  var html;
  if (extra == undefined) {extra = ""};

  switch (doc_type) {

    // shared
    case 'motif-db':
      return(`
	The name of a file of motifs ("motif database file") that contains ` + extra + `
      `);
    case 'motif-id':
      return(`
	The name of the ` + extra + ` motif, which is unique in the motif database file.
      `);
    case 'motif-alt-id':
      return(`
	An alternate name for the ` + extra + ` motif, which may be provided in the motif database file.
      `);
    case 'motif-width':
      return(`
	The width of the motif. No gaps are allowed in motifs supplied to ` + extra + `
        as it only works for motifs of a fixed width.
      `);
    case 'motif-cons':
      return(`
	A consensus sequence computed from the ` + extra + ` motif (as described <a href="#consensus_doc">below</a>).
      `);
    case 'motif-match-score':
     return(`
	The score for the match of a position in a sequence to a motif is
	computed by summing the appropriate entry from each column of the
	position-dependent scoring matrix that represents the motif. ` + extra + `
     `);
    case 'motif-match-p-value':
      return(`
	The <i>p</i>-value of a motif match is the probability of a single random
	subsequence of the length of the motif
	<a href="javascript:help_refine('pop_motif_match_score')">scoring</a>
	at least as well as the observed match.
      `);
    case 'bh-q-value-method':
      return(`
        ` + extra + ` estimates q-values from all the match <i>p</i>-values 
	using the method proposed by Benjamini & Hochberg (<i>Journal of the Royal Statistical Society B</i>, 57:289-300, 1995).
	See also Storey JD, Tibshirani R. Statistical significance for
	genome-wide studies, <i>Proc. Natl. Acad. Sci. USA</i> (2003) <b>100</b>:9440&ndash;9445.
      `);
    case 'bh-q-value':
      return(`
	The minimum False Discovery Rate (FDR) required to consider this match significant.</br>` + get_doc_text('bh-q-value-method', extra) + `
      `);
    case 'sdb-name':
      return(`
	The name of the (FASTA) sequence database file.
      `);
    case 'sdb-psp':
      return(`
	The name of the position specific priors (PSP) file.
      `);
    case 'sdb-dist':
      return(`
	The name of the binned distribution of priors file.
      `);
    case 'sdb-count':
      return(`
	The number of sequences in the database.
      `);
    case 'sdb-letters':
      return(`
	The number of letters in the sequence database.
      `);
    case 'lastmod':
      return(`
	The date of the last modification to the ` + extra + ` database.
      `);
    case 'sequence-id':
      return(`
        The identifier of the sequence (from the FASTA sequence header line)` + extra + `
      `);
    case 'sequence-name':
      return(`
	` + extra + `name of the sequence extracted from the sequence identifier (in the FASTA sequence header line).<br>
	When you use the <code>--parse-genomic--coord</code> option, the sequence name ends at the
	first colon ':' (if any) present in the sequence\'s FASTA identifier.  Typically this is the
	chromosome or contig name.  With the <code>--parse-genomic--coord</code> option,
	the start and stop positions are in 0-based coordinates relative to the sequence start given 
	in the FASTA sequence identifier (just after the sequence name).</td> </tr>
      `);
    case 'sequence-desc':
      return(`
        The description appearing after the identifier of the sequence in the FASTA header line.
      `);
    case 'sequence-name':
    case 'alph-name':
      return(`
	The name of the alphabet symbol.
      `);
    case 'alph-bg':
      return(`
	The frequency of the alphabet symbol as defined by the background model.
      `);
    case 'match-start-seq':
      return(`
	The start position of the ` + extra + `; 1-based sequence coordinates.
      `);
    case 'match-stop-seq':
      return(`
	The end position of the ` + extra + `; 1-based sequence coordinates.
      `);
    case 'match-start-genomic':
      return(`
	The start position of the ` + extra + `; genomic coordinates.
      `);
    case 'match-stop-genomic':
      return(`
	The end position of the ` + extra + `; genomic coordinates.
      `);
    case 'parse-genomic-coord':
      return(`
	` + extra + ` was run with the <code>--parse-genomic-coord</code> option
	and has split the sequence identifier into sequence name, sequence start and sequence end 
	in genomic coordinates.
      `);

    // AME
    case 'ame-pvalue':
      return(`
	The optimal enrichment <i>p</i>-value of the motif according to the statistical test;
	not adjusted for multiple tests.
      `);
    case 'ame-adj-pvalue':
      return(`
	The optimal enrichment <i>p</i>-value of the motif according to the statistical test,
        adjusted for multiple tests using a Bonferroni correction. ` + extra + `
	If the best <i>p</i>-value is <i>p</i> before adjustment,
        and the number of multiple tests is <i>n</i>, then the adjusted
        <i>p</i>-value is 1 - (1-<i>p</i>)<i><sup>n</sup></i>.
      `);
    case 'ame-evalue':
      return(`
	The expected number of motifs that would be as enriched in the
        (primary) sequences as this one.  The <i>E</i>-value is the adjusted <i>p</i>-value
        multiplied by the number of motifs in the motif file(s).
      `);

    // CentriMo
    case 'centrimo-adj-pvalue':
      return(`
        The statistical significance of the enrichment of the motif, adjusted for multiple tests. ` + extra + `
      `);
    case 'centrimo-evalue':
      var evalue_html = `
        at least one region as enriched for best matches to the motif as the reported region
	(or would have optimal average distance to the sequence center as low as observed, 
	if you used the <code>--cd</code> option).
      `;
      return(`
	The expected number motifs that would have ` + (extra ? extra : evalue_html) + `
	The <i>E</i>-value is the adjusted <i>p</i>-value multiplied by the number of motifs in the
	input files(s).</td> </tr>
      `);
    case 'centrimo-bin-width':
      return(`
        The width (in sequence positions) of the most enriched region (default),
        <b>or</b> two times the average distance between the center of the best site
        and the sequence center if you used the option <code>--cd</code>.
        A best match to the motif is counted as being in the region if
        the center of the motif falls in the region.
      `);
    case 'centrimo-sites-in-bin':
      return(`
	The number of (positive) sequences whose best match to the motif `
	+ (extra ? extra : "falls in the reported region (default) or anywhere in the sequence (if you used the option <code>--cd</code>).") + `
	<br>Note: This number may be less than the number of
	(positive) sequences that have a best match in the region.
	The reason for this is that a sequence may have many matches that score
	equally best.  If <i>n</i> matches have the best score in a sequence, 1/<i>n</i> is added to the
	appropriate bin for each match.</td> </tr>
      `);
    case 'centrimo-mult-tests':
      return(`
	This is the number of multiple tests (<i>n</i>) done for this motif.
	It was used to adjust the <i>p</i>-value of a region for
	multiple tests using the formula:
	<br>&nbsp;&nbsp;
	  <i>p</i>' = 1 - (1-<i>p</i>)<sup><i>n</i></sup> where <i>p</i> is the unadjusted <i>p</i>-value.
	<br>
	The number of multiple tests is the number of regions
	considered times the number of score thresholds considered.
	It depends on the motif length, sequence length, and the type of
	optimizations being done (central enrichment, local enrichment, central distance or
	score optimization).</td> </tr>
      `);

    // GOMo
    case 'gomo-go-term':
      return(`
        The Gene Ontology Consortium term for a specific role or locality.
        Used for annotating genes with their functions.
      `);
    case 'gomo-score':
      return( `
	A score generated as the <a href="https://en.wikipedia.org/wiki/Geometric_mean">
	geometric mean</a> of <a href="https://en.wikipedia.org/wiki/Mann-Whitney_U_test">rank-sum test(s)</a> 
	for the particular Gene Ontology term. The two groups compared by the rank-sum test are scores of genes annotated 
	with the GO term and scores of genes not annotated with the GO term.</td> </tr>
      `);
    case 'gomo-p-value':
      return( `
	An empirically generated <i>p</i>-value for the enrichment of the GO term.<br>
	The null hypothesis is that by shuffling the labels on gene scores, 
	any possible association between the set of genes that a GO term annotates is destroyed. 
	A large number of scores are generated using the null hypothesis and the number of null 
	hypothesis scores that are better than each of the real scores is summed and then divided 
	by the total null hypothesis scores generated to calculate a <i>p</i>-value.</td> </tr>
      `);

    // MAST

    // MCAST
    case 'mcast-cluster-score':
      return( `
        The score that the hidden Markov model created by MCAST assigned to the motif cluster.<br>
        This is the sum of the scores of the individual motif matches in the cluster, plus a
        gap penalty, <i>g</i>, multiplied by the total size of the inter-motif gaps
        in the cluster.  Individual motif match scores are log2(<i>P(s)/p</i>), where <i>s</i> is the 
        <a href="javascript:help_refine('pop_motif_match_score')">log-odds score</a> 
        of the motif match, <i>P(s)</i> is the 
        <a href="javascript:help_refine('pop_motif_match_pvalue')"><i>p</i>-value</a> 
	of the motif match, and <i>p</i> is the user-specified <i>p</i>-value threshold (default: 0.0005).
        <div class="active" id="pop_motif_match_score_act"></div>
        <div class="active" id="pop_motif_match_pvalue_act"></div>
      `);
    case 'mcast-cluster-p-value':
      return( `
	The <i>p</i>-value of the motif cluster score.<br>
	MCAST estimates <i>p</i>-values by fitting an exponential distribution
	to the observed motif cluster scores.
      `);
    case 'mcast-cluster-E-value':
      return( `
        The <i>E</i>-value of the motif cluster score.<br>
	The <i>E</i>-value is an estimate of the <i>number</i> of false positive matches
	with <i>p</i>-values at least as good as this match\'s.  
        MCAST estimates this by multiplying the motif cluster score <i>p</i>-value
        times the (estimated) number of random matches found in the search.
      `);

    // Tomtom
    case 'tomtom-offset':
      return( `
        The offset of the query motif relative to the target motif in the optimal alignment.<br>
 	A positive value indicates the query is shifted right.
      `);
    case 'tomtom-p-value':
      return( `
        The probability that a random motif of the same width as the target would have an 
	optimal alignment with a match score as good or better than the target's.<br>
	Tomtom estimates the <i>p</i>-value using a null model consisting of sampling
	motif columns from all the columns in the set of target motifs.
      `);
    case 'tomtom-E-value':
      return( `
	The expected number of false positives in the matches up to this point.<br>
	Tomtom estimates the <i>E</i>-value by multiplying the <i>p</i>-value by
	the total number of target motifs in all the target databases.
      `);
    case 'tomtom-overlap':
      return( `
	The number of motif columns that overlap in the optimal alignment.
      `);
    case 'tomtom-orientation':
      return( `
	The orientation of the target motif that gave the optimal alignment. ` + extra + `
      `);
  }

} // get_doc_text

//
// Function to replace the innerHTML of element "id" with an HTML paragraph
// containing the text for 'doc_type', which is known to function get_doc_text.
// This function can be used in help pop-ups.
//
function print_doc_para(id, doc_type, extra) {
  html = `<p>` + get_doc_text(doc_type, extra) + `</p>`; 
  document.getElementById(id).insertAdjacentHTML('beforeend', html);
} // print_doc_para
</script>
    <script>
function make_alpha_bg_table(alph, freqs) {
  function colour_symbol(index) {
    var span = document.createElement("span");
    span.appendChild(document.createTextNode(alph.get_symbol(index)));
    span.style.color = alph.get_colour(index);
    span.className = "alpha_symbol";
    return span;
  }
  var table, thead, tbody, row, th, span, i;
  // create table
  table = document.createElement("table");
  table.className = "alpha_bg_table";
  // create header
  thead = document.createElement("thead");
  table.appendChild(thead);
  row = thead.insertRow(thead.rows.length);
  if (alph.has_complement()) {
    add_text_header_cell(row, "Name", "pop_alph_name");
    if (freqs != null) add_text_header_cell(row, "Freq.", "pop_alph_freq");
    if (alph.has_bg()) add_text_header_cell(row, "Bg.", "pop_alph_bg");
    add_text_header_cell(row, "");
    add_text_header_cell(row, "");
    add_text_header_cell(row, "");
    if (alph.has_bg()) add_text_header_cell(row, "Bg.", "pop_alph_bg");
    if (freqs != null) add_text_header_cell(row, "Freq.", "pop_alph_freq");
    add_text_header_cell(row, "Name", "pop_alph_name");
  } else {
    add_text_header_cell(row, "");
    add_text_header_cell(row, "Name", "pop_alph_name");
    if (freqs != null) add_text_header_cell(row, "Freq.", "pop_alph_freq");
    if (alph.has_bg()) add_text_header_cell(row, "Bg.", "pop_alph_bg");
  }
  // add alphabet entries
  tbody = document.createElement("tbody");
  table.appendChild(tbody);
  if (alph.has_complement()) {
    for (i = 0; i < alph.get_size_core(); i++) {
      var c = alph.get_complement(i);
      if (i > c) continue;
      row = tbody.insertRow(tbody.rows.length);
      add_text_cell(row, alph.get_name(i));
      if (freqs != null) add_text_cell(row, "" + freqs[i]);
      if (alph.has_bg()) add_text_cell(row, "" + alph.get_bg_freq(i));
      add_cell(row, colour_symbol(i)); 
      add_text_cell(row, "~");
      add_cell(row, colour_symbol(c)); 
      if (alph.has_bg()) add_text_cell(row, "" + alph.get_bg_freq(c));
      if (freqs != null) add_text_cell(row, "" + freqs[c]);
      add_text_cell(row, alph.get_name(c));
    }
  } else {
    for (i = 0; i < alph.get_size_core(); i++) {
      row = tbody.insertRow(tbody.rows.length);
      add_cell(row, colour_symbol(i)); 
      add_text_cell(row, alph.get_name(i));
      if (freqs != null) add_text_cell(row, "" + freqs[i]);
      if (alph.has_bg()) add_text_cell(row, "" + alph.get_bg_freq(i));
    }
  }
  return table;
}

</script>
    <script>
      // 
      // return true if any part of the passed element is visible in the viewport
      //
      function element_in_viewport(elem) {
        var rect;
        try {
          rect = elem.getBoundingClientRect();
        } catch (e) {
          return false;
        }
        return (
            rect.top < (window.innerHeight || document.body.clientHeight) &&
            rect.bottom > 0 &&
            rect.left < (window.innerWidth || document.body.clientWidth) &&
            rect.right > 0
            );
      }

      //
      // Functions to delay a drawing task until it is required or it would not lag the display to do so
      //

      // a list of items still to be drawn
      var drawable_list = [];
      // the delay between drawing objects that are not currently visible
      var draw_delay = 1;
      // the delay after a user interaction
      var user_delay = 300;
      // the delay after a user has stopped scrolling and is viewing the stuff drawn on the current page
      var stop_delay = 300;
      // the timer handle; allows resetting of the timer after user interactions
      var draw_timer = null;

      //
      // Drawable
      //
      // elem - a page element which defines the position on the page that drawing is to be done
      // task - an object with the method run which takes care of painting the object
      //
      var Drawable = function(elem, task) {
        this.elem = elem;
        this.task = task;
      }

      //
      // Drawable.is_visible
      //
      // Determines if the element is visible in the viewport
      //
      Drawable.prototype.is_visible = function() {
        return element_in_viewport(this.elem);
      }

      //
      // Drawable.run
      //
      // Run the task held by the drawable
      Drawable.prototype.run = function() {
        if (this.task) this.task.run();
        this.task = null;
      }

      //
      // Drawable.run
      //
      // Run the task iff visible
      // returns true if the task ran or has already run
      Drawable.prototype.run_visible = function() {
        if (this.task) {
          if (element_in_viewport(this.elem)) {
            this.task.run();
            this.task = null;
            return true;
          }
          return false;
        } else {
          return true;
        }
      }

      //
      // draw_on_screen
      //
      // Checks each drawable object and draws those on screen.
      //
      function draw_on_screen() {
        var found = false;
        for (var i = 0; i < drawable_list.length; i++) {
          if (drawable_list[i].run_visible()) {
            drawable_list.splice(i--, 1);
            found = true;
          }
        }
        return found;
      }

      //
      // process_draw_tasks
      //
      // Called on a delay to process the next available
      // draw task.
      //
      function process_draw_tasks() {
        var delay = draw_delay;
        draw_timer = null;
        if (drawable_list.length == 0) return; //no more tasks
        if (draw_on_screen()) {
          delay = stop_delay; //give the user a chance to scroll
        } else {
          //get next task
          var drawable = drawable_list.shift();
          drawable.task.run();
        }
        //allow UI updates between tasks
        draw_timer = window.setTimeout("process_draw_tasks()", delay);
      }

      //
      // delayed_process_draw_tasks
      //
      // Call process_draw_tasks after a short delay.
      // The delay serves to group multiple redundant events.       
      // Should be set as event handler for onscroll and onresize.
      //
      function delayed_process_draw_tasks() {
        //reset the timer
        if (drawable_list.length > 0) { 
          if (draw_timer != null) clearTimeout(draw_timer);
          draw_timer = window.setTimeout("process_draw_tasks()", user_delay);
        }
      }

      //
      // add_draw_task
      //
      // Add a drawing task to be called immediately if it is
      // visible, or to be called on a delay to reduce stuttering
      // effect on the web browser.
      function add_draw_task(elem, task) {
        drawable = new Drawable(elem, task);
        if (drawable.is_visible()) {
          task.run();
        } else {
          drawable_list.push(drawable);
          //reset timer
          if (draw_timer != null) clearTimeout(draw_timer);
          draw_timer = window.setTimeout("process_draw_tasks()", user_delay);
        }
      }

</script>
    <script>
//======================================================================
// start Alphabet object
//======================================================================
var Alphabet = function(alphabet, background) {
  "use strict";
  var i, j, sym, aliases, complement, comp_e_sym, ambigs, generate_background;
  generate_background = (background == null);
  if (generate_background) {
    background = [];
    for (i = 0; i < alphabet.ncore; i++) background[i] = 1.0 / alphabet.ncore;
  } else if (alphabet.ncore != background.length) {
    throw new Error("The background length does not match the alphabet length.");
  }
  this.name = alphabet.name;
  this.like = (alphabet.like != null ? alphabet.like.toUpperCase() : null);
  this.ncore = alphabet.ncore;
  this.symbols = alphabet.symbols;
  this.background = background;
  this.genbg = generate_background;
  this.encode = {};
  this.encode2core = {};
  this.complement = {};
  // check if all symbols are same case
  var seen_uc = false;
  var seen_lc = false;
  var check_case = function (syms) {
    var s, sym;
    if (typeof syms === "string") {
      for (s = 0; s < syms.length; s++) {
        sym = syms.charAt(s);
        if (sym >= 'a' && sym <= 'z') seen_lc = true;
        else if (sym >= 'A' && sym <= 'Z') seen_uc = true;
      }
    }
  };
  for (i = 0; i < this.symbols.length; i++) {
    check_case(this.symbols[i].symbol);
    check_case(this.symbols[i].aliases);
  }
  // now map symbols to indexes
  var update_array = function(array, syms, index) {
    var s, sym;
    if (typeof syms === "string") {
      for (s = 0; s < syms.length; s++) {
        sym = syms.charAt(s);
        array[sym] = index;
        // when only a single case is used, then encode as case insensitive
        if (seen_uc != seen_lc) {
          if (sym >= 'a' && sym <= 'z') {
            array[sym.toUpperCase()] = index;
          } else if (sym >= 'A' && sym <= 'Z') {
            array[sym.toLowerCase()] = index;
          }
        }
      }
    }
  }
  // map core symbols to index
  for (i = 0; i < this.ncore; i++) {
    update_array(this.encode2core, this.symbols[i].symbol, i);
    update_array(this.encode, this.symbols[i].symbol, i);
    update_array(this.encode2core, this.symbols[i].aliases, i);
    update_array(this.encode, this.symbols[i].aliases, i);
  }
  // map ambiguous symbols to index
  ambigs = {};
  for (i = this.ncore; i < this.symbols.length; i++) {
    update_array(this.encode, this.symbols[i].symbol, i);
    update_array(this.encode, this.symbols[i].aliases, i);
    ambigs[this.symbols[i].equals] = i;
  }
  // determine complements
  for (i = 0; i < this.ncore; i++) {
    complement = this.symbols[i].complement;
    if (typeof complement === "string") {
      this.complement[i] = this.encode2core[complement];
    }
  }
  next_symbol:
  for (i = this.ncore; i < this.symbols.length; i++) {
    complement = "";
    for (j = 0; j < this.symbols[i].equals.length; j++) {
      comp_e_sym = this.complement[this.encode2core[this.symbols[i].equals.charAt(j)]];
      if (typeof comp_e_sym !== "number") continue next_symbol;
      complement += this.symbols[comp_e_sym].symbol;
    }
    complement = complement.split("").sort().join("");
    if (typeof ambigs[complement] === "number") {
      this.complement[i] = ambigs[complement];
    }
  }
  // determine case insensitivity
  this.case_insensitive = true;
  if (seen_uc == seen_lc) {
    // when there is a mixture of cases it probably won't
    // be case insensitive but we still need to check
    loop:
    for (i = 0; i < this.symbols.length; i++) {
      sym = this.symbols[i].symbol;
      if (sym >= 'A' && sym <= 'Z') {
        if (this.encode[sym.toLowerCase()] != i) {
          this.case_insensitive = false;
          break loop;
        }
      } else if (sym >= 'a' && sym <= 'z') {
        if (this.encode[sym.toUpperCase()] != i) {
          this.case_insensitive = false;
          break loop;
        }
      }
      aliases = this.symbols[i].aliases;
      if (aliases != null) {
        for (j = 0; j < aliases.length; j++) {
          sym = aliases.charAt(j);
          if (sym >= 'A' && sym <= 'Z') {
            if (this.encode[sym.toLowerCase()] != i) {
              this.case_insensitive = false;
              break loop;
            }
          } else if (sym >= 'a' && sym <= 'z') {
            if (this.encode[sym.toUpperCase()] != i) {
              this.case_insensitive = false;
              break loop;
            }
          }
        }
      }
    }
  }
  // normalise aliases to remove the prime symbol and eliminate
  // the alternate cases when the alphabet is case insensitive
  var seen, out;
  for (i = 0; i < this.symbols.length; i++) {
    sym = this.symbols[i].symbol;
    aliases = this.symbols[i].aliases;
    if (typeof aliases != "string") aliases = "";
    seen = {};
    out = [];
    if (this.case_insensitive) {
      sym = sym.toUpperCase();
      aliases = aliases.toUpperCase();
    }
    seen[sym] = true;
    for (j = 0; j < aliases.length; j++) {
      if (!seen[aliases.charAt(j)]) {
        seen[aliases.charAt(j)] = true;
        out.push(aliases.charAt(j));
      }
    }
    this.symbols[i].aliases = out.sort().join("");
  }
};
// return the name of the alphabet
Alphabet.prototype.get_alphabet_name = function() {
  return this.name;
};
// return if the alphabet can be complemented
Alphabet.prototype.has_complement = function() {
  return (typeof this.symbols[0].complement === "string");
};
// return true if an uppercase letter has the same meaning as the lowercase form
Alphabet.prototype.is_case_insensitive = function() {
  return this.case_insensitive;
};
// return the information content of an alphabet letter
Alphabet.prototype.get_ic = function() {
  return Math.log(this.ncore) / Math.LN2;
};
// return the count of the core alphabet symbols
Alphabet.prototype.get_size_core = function() {
  return this.ncore;
};
// return the count of all alphabet symbols
Alphabet.prototype.get_size_full = function() {
  return this.symbols.length;
};
// return the symbol for the given alphabet index
Alphabet.prototype.get_symbol = function(alph_index) {
  "use strict";
  if (alph_index < 0 || alph_index >= this.symbols.length) {
    throw new Error("Alphabet index out of bounds");
  }
  return this.symbols[alph_index].symbol;
};
// return the aliases for the given alphabet index
Alphabet.prototype.get_aliases = function(alph_index) {
  "use strict";
  if (alph_index < 0 || alph_index >= this.symbols.length) {
    throw new Error("Alphabet index out of bounds");
  }
  var sym_obj = this.symbols[alph_index];
  return (sym_obj.aliases != null ? sym_obj.aliases : "");
};
// return the name for the given alphabet index
Alphabet.prototype.get_name = function(alph_index) {
  "use strict";
  var sym;
  if (alph_index < 0 || alph_index >= this.symbols.length) {
    throw new Error("Alphabet index out of bounds");
  }
  sym = this.symbols[alph_index];
  return (typeof sym.name === "string" ? sym.name : sym.symbol);
};
// return the alphabet it is like or null
Alphabet.prototype.get_like = function() {
  "use strict";
  return this.like;
};
// return the index of the complement for the given alphabet index
Alphabet.prototype.get_complement = function(alph_index) {
  var comp_e_sym = this.complement[alph_index];
  if (typeof comp_e_sym === "number") {
    return comp_e_sym;
  } else {
    return -1;
  }
};
// return a string containing the core symbols
Alphabet.prototype.get_symbols = function() {
  "use strict";
  var i, core_symbols;
  core_symbols = "";
  for (i = 0; i < this.ncore; i++) {
    core_symbols += this.symbols[i].symbol;
  }
  return core_symbols;
};
// return if the background was not a uniform generated background
Alphabet.prototype.has_bg = function() {
  "use strict";
  return !this.genbg;
};
// get the background frequency for the index
Alphabet.prototype.get_bg_freq = function(alph_index) {
  "use strict";
  var freq, i, symbols;
  if (alph_index >= 0) {
    if (alph_index < this.ncore) {
      return this.background[alph_index];
    } else if (alph_index < this.symbols.length) {
      freq = 0;
      symbols = this.symbols[alph_index].equals;
      for (i = 0; i < symbols.length; i++) {
        freq += this.background[this.encode2core[symbols.charAt(i)]];
      }
      return freq;
    } 
  }
  throw new Error("The alphabet index is out of range.");
};
// get the colour of the index
Alphabet.prototype.get_colour = function(alph_index) {
  "use strict";
  if (alph_index < 0 || alph_index >= this.symbols.length) {
    throw new Error("BAD_ALPHABET_INDEX");
  }
  if (typeof this.symbols[alph_index].colour != "string") {
    return "black";
  }
  return "#" + this.symbols[alph_index].colour;
};
// get the rgb components of the colour at the index
Alphabet.prototype.get_rgb = function(alph_index) {
  "use strict";
  if (alph_index < 0 || alph_index >= this.symbols.length) {
    throw new Error("BAD_ALPHABET_INDEX");
  }
  if (typeof this.symbols[alph_index].colour != "string") {
    return {"red": 0, "green": 0, "blue": 0};
  }
  var colour = this.symbols[alph_index].colour;
  var red = parseInt(colour.substr(0, 2), 16) / 255;
  var green = parseInt(colour.substr(2, 2), 16) / 255;
  var blue = parseInt(colour.substr(4, 2), 16) / 255;
  return {"red": red, "green": green, "blue": blue};
};
// convert a symbol into the index
Alphabet.prototype.get_index = function(letter) {
  "use strict";
  var alph_index;
  alph_index = this.encode[letter];
  if (typeof alph_index === "undefined") {
    return -1;
  }
  return alph_index;
};
// convert a symbol into the list of core indexes that it equals
Alphabet.prototype.get_indexes = function(letter) {
  "use strict";
  var alph_index, comprise_str, i, comprise_list;
  alph_index = this.encode[letter];
  if (typeof alph_index === "undefined") {
    throw new Error("Unknown letter");
  }
  comprise_str = this.symbols[alph_index].equals;
  comprise_list = [];
  if (typeof comprise_str == "string") {
    for (i = 0; i < comprise_str.length; i++) {
      comprise_list.push(this.encode2core[comprise_str.charAt(i)]);
    }
  } else {
    comprise_list.push(alph_index);
  }
  return comprise_list;
};
// check if a symbol is the primary way of representing the symbol in the alphabet
Alphabet.prototype.is_prime_symbol = function(letter) {
  var alph_index;
  alph_index = this.encode[letter];
  if (alph_index == null) return false;
  if (this.is_case_insensitive()) {
    return (this.symbols[alph_index].symbol.toUpperCase() == letter.toUpperCase());
  } else {
    return (this.symbols[alph_index].symbol == letter);
  }
};
// compare 2 alphabets
Alphabet.prototype.equals = function(other) {
  "use strict";
  var i, sym1, sym2;
  // first check that it's actually an alphabet object
  if (!(typeof other === "object" && other != null && other instanceof Alphabet)) {
    return false;
  }
  // second shortcircuit if it's the same object
  if (this === other) return true;
  // compare
  if (this.name !== other.name) return false;
  if (this.ncore !== other.ncore) return false;
  if (this.symbols.length !== other.symbols.length) return false;
  for (i = 0; i < this.symbols.length; i++) {
    sym1 = this.symbols[i];
    sym2 = other.symbols[i];
    if (sym1.symbol !== sym2.symbol) return false;
    if (sym1.aliases !== sym2.aliases) return false;
    if (sym1.name !== sym2.name) return false;
    if (typeof sym1.colour !== typeof sym2.colour || 
        (typeof sym1.colour === "string" && typeof sym2.colour === "string" &&
         parseInt(sym1.colour, 16) != parseInt(sym2.colour, 16))) {
      return false;
    }
    if (sym1.complement !== sym2.complement) return false;
    if (sym1.equals !== sym2.equals) return false;
  }
  return true;
};
Alphabet.prototype.check_core_subset = function(super_alph) {
  var complement_same = true;
  var seen_set = {};
  var sub_i, sub_symbol, super_i, super_symbol;
  for (sub_i = 0; sub_i < this.ncore; sub_i++) {
    sub_symbol = this.symbols[sub_i];
    super_i = super_alph.encode[sub_symbol.symbol]; 
    if (super_i == null) return 0;
    super_symbol = super_alph.symbols[super_i];
    if (seen_set[super_i]) return 0;
    seen_set[super_i] = true;
    // check complement
    if (sub_symbol.complement != null && super_symbol.complement != null) {
      if (super_alph.encode[sub_symbol.complement] != super_alph.encode[super_symbol.complement]) {
        complement_same = false;
      }
    } else if (sub_symbol.complement != null || super_symbol.complement != null) {
      complement_same = false;
    }
  }
  return (complement_same ? 1 : -1);
};
// convert a sequence to its reverse complement
Alphabet.prototype.invcomp_seq = function(seq) {
  "use strict";
  var syms, i, e_sym, comp_e_sym;
  if (!this.has_complement()) throw new Error("Alphabet must be complementable");
  syms = seq.split("");
  for (i = 0; i < syms.length; i++) {
    e_sym = this.encode[syms[i]];
    if (typeof e_sym === "undefined") {
      e_sym = this.ncore; // wildcard
    }
    comp_e_sym = this.complement[e_sym];
    if (typeof comp_e_sym === "undefined") {
      comp_e_sym = e_sym; // not complementable
    }
    syms[i] = this.symbols[comp_e_sym].symbol;
  }
  return syms.reverse().join("");
};
// convert the alphabet to the text version
Alphabet.prototype.as_text = function() {
  "use strict";
  function name_as_text(name) {
    var i, c, out;
    out = "\"";
    for (i = 0; i < name.length; i++) {
      c = name.charAt(i);
      if (c == "\"") {
        out += "\\\"";
      } else if (c == "/") {
        out += "\\/";
      } else if (c == "\\") {
        out += "\\\\";
      } else {
        out += c;
      }
    }
    out += "\"";
    return out;
  }
  function symbol_as_text(sym) {
    var out;
    out = sym.symbol;
    if (typeof sym.name === "string" && sym.name != sym.symbol) {
      out += " " + name_as_text(sym.name);
    }
    if (typeof sym.colour === "string") {
      out += " " + sym.colour;
    }
    return out;
  }
  var out, i, j, c, sym;
  out = "";
  // output core symbols with 2 way complements
  for (i = 0; i < this.ncore; i++) {
    c = this.complement[i];
    if (typeof c === "number" && i < c && this.complement[c] === i) {
      out += symbol_as_text(this.symbols[i]) + " ~ " + symbol_as_text(this.symbols[c]) + "\n";  
    }
  }
  // output core symbols with no complement
  for (i = 0; i < this.ncore; i++) {
    if (typeof this.complement[i] === "undefined") {
      out += symbol_as_text(this.symbols[i]) + "\n";
    }
  }
  // output ambiguous symbols that have comprising characters
  for (i = this.ncore; i < this.symbols.length; i++) {
    if (this.symbols[i].equals.length == 0) break;
    out += symbol_as_text(this.symbols[i]) + " = " + this.symbols[i].equals + "\n";
    if (typeof this.symbols[i].aliases === "string") {
      for (j = 0; j < this.symbols[i].aliases.length; j++) {
        if (this.symbols[i].aliases.charAt(j) == this.symbols[i].symbol) continue;
        out += this.symbols[i].aliases.charAt(j) + " = " + this.symbols[i].equals + "\n";
      }
    }
  }
  // output aliases of core symbols
  for (i = 0; i < this.ncore; i++) {
    if (typeof this.symbols[i].aliases === "string") {
      for (j = 0; j < this.symbols[i].aliases.length; j++) {
        if (this.symbols[i].aliases.charAt(j) == this.symbols[i].symbol) continue;
        out += this.symbols[i].aliases.charAt(j) + " = " + this.symbols[i].symbol + "\n";
      }
    }
  }
  // output gap symbols
  i = this.symbols.length - 1;
  if (this.symbols[i].equals.length == 0) {
    out += symbol_as_text(this.symbols[i]) + " =\n";
    if (typeof this.symbols[i].aliases === "string") {
      for (j = 0; j < this.symbols[i].aliases.length; j++) {
        if (this.symbols[i].aliases.charAt(j) == this.symbols[i].symbol) continue;
        out += this.symbols[i].aliases.charAt(j) + " =\n";
      }
    }
  }
  return out;
};
// output the alphabet as it appears in minimal MEME format
Alphabet.prototype.as_meme = function() {
  "use strict";
  function name_as_text(name) {
    var i, c, out;
    out = "\"";
    for (i = 0; i < name.length; i++) {
      c = name.charAt(i);
      if (c == "\"") {
        out += "\\\"";
      } else if (c == "/") {
        out += "\\/";
      } else if (c == "\\") {
        out += "\\\\";
      } else {
        out += c;
      }
    }
    out += "\"";
    return out;
  }
  if (this.equals(AlphStd.DNA)) {
    return "ALPHABET= ACGT\n";
  } else if (this.equals(AlphStd.PROTEIN)) {
    return "ALPHABET= ACDEFGHIKLMNPQRSTVWY\n";
  } else {
    return "ALPHABET" + 
      (this.name != null ? " " + name_as_text(this.name) : "") + 
      (this.like != null ? " " + this.like + "-LIKE" : "") + "\n" +
      this.as_text() + "END ALPHABET\n";
  }
};

// Returns a table showing all the letters in the alphabet
Alphabet.prototype.as_table = function() {
  "use strict";
  var i, j, row, th, td, aliases, equals, sym;
  var table = document.createElement("table");
  // create the core symbol header
  row = table.insertRow(table.rows.length);
  th = document.createElement("th");
  th.appendChild(document.createTextNode("Symbol(s)"));
  row.appendChild(th);
  th = document.createElement("th");
  th.appendChild(document.createTextNode("Name"));
  row.appendChild(th);
  th = document.createElement("th");
  if (this.has_complement()) {
    th.appendChild(document.createTextNode("Complement"));
  }
  row.appendChild(th);
  // list the core symbols
  for (i = 0; i < this.ncore; i++) {
    row = table.insertRow(table.rows.length);
    td = document.createElement("td");
    if (this.symbols[i].colour != null) {
      td.style.color = '#' + this.symbols[i].colour;
    }
    td.appendChild(document.createTextNode(this.symbols[i].symbol));
    aliases = this.get_aliases(i);
    if (aliases.length > 0) {
      td.appendChild(document.createTextNode(' ' + aliases.split('').join(' ')));
    }
    row.appendChild(td);
    td = document.createElement("td");
    if (this.symbols[i].name != null) {
      td.appendChild(document.createTextNode(this.symbols[i].name));
    }
    row.appendChild(td);
    td = document.createElement("td");
    if (this.symbols[i].complement != null) {
      td.style.color = this.get_colour(this.get_index(this.symbols[i].complement));
      td.appendChild(document.createTextNode(this.symbols[i].complement));
    }
    row.appendChild(td);
  }
  // create the ambiguous symbol header
  row = table.insertRow(table.rows.length);
  th = document.createElement("th");
  th.appendChild(document.createTextNode("Symbol(s)"));
  row.appendChild(th);
  th = document.createElement("th");
  th.appendChild(document.createTextNode("Name"));
  row.appendChild(th);
  th = document.createElement("th");
  th.appendChild(document.createTextNode("Matches"));
  row.appendChild(th);
  // list the ambiguous symbols
  for (i = this.ncore; i < this.symbols.length; i++) {
    row = table.insertRow(table.rows.length);
    td = document.createElement("td");
    if (this.symbols[i].colour != null) {
      td.style.color = '#' + this.symbols[i].colour;
    }
    td.appendChild(document.createTextNode(this.symbols[i].symbol));
    aliases = this.get_aliases(i);
    if (aliases.length > 0) {
      td.appendChild(document.createTextNode(' ' + aliases.split('').join(' ')));
    }
    row.appendChild(td);
    td = document.createElement("td");
    if (this.symbols[i].name != null) {
      td.appendChild(document.createTextNode(this.symbols[i].name));
    }
    row.appendChild(td);
    td = document.createElement("td");
    equals = this.symbols[i].equals.split('');
    for (j = 0; j < equals.length; j++) {
      if (j != 0) td.appendChild(document.createTextNode(' '));
      sym = document.createElement("span");
      sym.style.color = this.get_colour(this.get_index(equals[j]));
      sym.appendChild(document.createTextNode(equals[j]));
      td.appendChild(sym);
    }
    row.appendChild(td);
  }
  return table;
};

// returns a dictionary of the colours for EPS
Alphabet.prototype._as_eps_dict = function() {
  "use strict";
  var i, sym, rgb;
  var out = "/fullColourDict <<\n";
  for (i = 0; i < this.ncore; i++) {
    sym = this.get_symbol(i);
    sym = sym.replace(/\\/g, "\\\\");
    sym = sym.replace(/\(/g, "\\(");
    sym = sym.replace(/\)/g, "\\)");
    rgb = this.get_rgb(i);
    out += " (" + sym + ") [" + rgb.red.toFixed(4) + " " + rgb.green.toFixed(4) + " " + rgb.blue.toFixed(4) + "]\n";
  }
  out += ">> def\n";
  out += "/mutedColourDict <<\n";
  for (i = 0; i < this.ncore; i++) {
    sym = this.get_symbol(i);
    sym = sym.replace(/\\/g, "\\\\");
    sym = sym.replace(/\(/g, "\\(");
    sym = sym.replace(/\)/g, "\\)");
    rgb = Alphabet.lighten_colour(this.get_rgb(i));
    out += " (" + sym + ") [" + rgb.red.toFixed(4) + " " + rgb.green.toFixed(4) + " " + rgb.blue.toFixed(4) + "]\n";
  }
  out += ">> def\n";
  return out;
};

// return the alphabet name or a list of primary symbols
Alphabet.prototype.toString = function() {
  "use strict";
  if (this.name != null) {
    return this.name;
  } else {
    return this.get_symbols();
  }
};

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Helper functions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// Convert a colour specified in RGB colourspace values into LAB colourspace
Alphabet.rgb2lab = function(rgb) {
  "use strict";
  var xyzHelper, labHelper;
  // XYZ helper
  xyzHelper = function(value) {
    if (value > 0.0445) {
      value = (value + 0.055) / 1.055;
      value = Math.pow(value, 2.4);
    } else {
      value /= 12.92;
    }
    value *= 100;
    return value;
  };
  // lab helper
  labHelper = function(value) {
    if (value > 0.008856) {
      value = Math.pow(value, 1.0 / 3.0);
    } else {
      value = (7.787 * value) + (16.0 / 116.0);
    }
    return value;
  };
  // convert into XYZ colourspace
  var c1, c2, c3;
  if (typeof rgb == "number") {
    c1 = xyzHelper(((rgb >> 16) & 0xFF) / 255.0);
    c2 = xyzHelper(((rgb >> 8) & 0xFF) / 255.0);
    c3 = xyzHelper((rgb & 0xFF) / 255.0);
  } else {
    c1 = xyzHelper(rgb.red);
    c2 = xyzHelper(rgb.green);
    c3 = xyzHelper(rgb.blue);
  }
  var x = (c1 * 0.4124) + (c2 * 0.3576) + (c3 * 0.1805);
  var y = (c1 * 0.2126) + (c2 * 0.7152) + (c3 * 0.0722);
  var z = (c1 * 0.0193) + (c2 * 0.1192) + (c3 * 0.9505);
  // convert into Lab colourspace
  c1 = labHelper(x / 95.047);
  c2 = labHelper(y / 100.0);
  c3 = labHelper(z / 108.883);
  var l = (116.0 * c2) - 16;
  var a = 500.0 * (c1 - c2);
  var b = 200.0 * (c2 - c3);
  return {"l": l, "a": a, "b": b};
};

// Convert a colour specified in HSV colourspace into RGB colourspace
Alphabet.hsv2rgb = function(hue, sat, value, output_object) {
  // achromatic (grey)
  var r = value;
  var g = value;
  var b = value;
  if (sat != 0) {
    var h = hue / 60.0;
    var i = Math.floor(h);
    var f = h - i;
    var p = value * (1.0 - sat);
    var q = value * (1.0 - (sat * f));
    var t = value * (1.0 - (sat * (1.0 - f)));
    if (i == 0) {
      r = value;
      g = t;
      b = p;
    } else if (i == 1) {
      r = q;
      g = value;
      b = p;
    } else if (i == 2) {
      r = p;
      g = value;
      b = t;
    } else if (i == 3) {
      r = p;
      g = q;
      b = value;
    } else if (i == 4) {
      r = t;
      g = p;
      b = value;
    } else {
      r = value;
      g = p;
      b = q;
    }
  }
  if (output_object) {
    return {"red": r, "green": g, "blue": b};
  } else {
    return (Math.floor(r * 255) << 15) | (Math.floor(g * 255) << 8) | (Math.floor(b * 255));
  }
};

// Calculate a distance score between two colours in LAB colourspace
Alphabet.lab_dist = function(lab1, lab2) {
  var c1 = Math.sqrt((lab1.l * lab1.l) + (lab1.a * lab1.a));
  var c2 = Math.sqrt((lab2.l * lab2.l) + (lab2.a * lab2.a));
  var dc = c1 - c2;
  var dl = lab1.l - lab2.l;
  var da = lab1.a - lab2.a;
  var db = lab1.b - lab2.b;
  // we don't want NaN due to rounding errors so fudge things a bit...
  var dh = 0;
  var dh_squared = (da * da) + (db * db) - (dc * dc);
  if (dh_squared > 0) {
    dh = Math.sqrt(dh_squared);
  }
  var first = dl;
  var second = dc / (1.0 + (0.045 * c1));
  var third = dh / (1.0 + (0.015 * c1));
  return Math.sqrt((first * first) + (second * second) + (third * third));
};

// convert an RGB value into a HSL value
Alphabet.rgb2hsl = function(rgb) {
  "use strict";
  var min, max, delta, h, s, l, r, g, b;
  if (typeof rgb == "number") {
    r = ((rgb >> 16) & 0xFF) / 255.0;
    g = ((rgb >> 8) & 0xFF) / 255.0;
    b = (rgb & 0xFF) / 255.0;
  } else {
    r = rgb.red;
    g = rgb.green;
    b = rgb.blue;
  }
  min = Math.min(r, g, b);
  max = Math.max(r, g, b);
  delta = max - min;
  l = min + (delta / 2);
  if (max == min) {
    h = 0; // achromatic (grayscale)
    s = 0;
  } else {
    if (l > 0.5) {
      s = delta / (2 - max - min);
    } else {
      s = delta / (max + min);
    }
    if (max == r) {
      h = (g - b) / delta;
      if (g < b) h += 6;
    } else if (max == g) {
      h = ((b - r) / delta) + 2;
    } else {
      h = ((r - g) / delta) + 4;
    }
    h /= 6;
  }
  return {"h": h, "s": s, "l": l};
};

// convert a HSL value into an RGB value
Alphabet.hsl2rgb = function(hsl, output_object) {
  "use strict";
  function _hue(p, q, t) {
    "use strict";
    if (t < 0) t += 1;
    else if (t > 1) t -= 1;
    if (t < (1.0 / 6.0)) {
      return p + ((q - p) * 6.0 * t);
    } else if (t < 0.5) {
      return q;
    } else if (t < (2.0 / 3.0)) {
      return p + ((q - p) * ((2.0 / 3.0) - t) * 6.0);
    } else {
      return p;
    }
  }
  var r, g, b, p, q;
  if (hsl.s == 0) {
    // achromatic (grayscale)
    r = hsl.l;
    g = hsl.l;
    b = hsl.l;
  } else {
    if (hsl.l < 0.5) {
      q = hsl.l * (1 + hsl.s);
    } else {
      q = hsl.l + hsl.s - (hsl.l * hsl.s);
    }
    p = (2 * hsl.l) - q;
    r = _hue(p, q, hsl.h + (1.0 / 3.0));
    g = _hue(p, q, hsl.h);
    b = _hue(p, q, hsl.h - (1.0 / 3.0));
  }
  if (output_object) {
    return {"red": r, "green": g, "blue": b};
  } else {
    return (Math.floor(r * 255) << 15) | (Math.floor(g * 255) << 8) | (Math.floor(b * 255));
  }
};

Alphabet.lighten_colour = function(rgb) {
  "use strict";
  var hsl = Alphabet.rgb2hsl(rgb);
  hsl.l += (1.0 - hsl.l) * 2 / 3;
  return Alphabet.hsl2rgb(hsl, typeof rgb != "number");
};

//======================================================================
// end Alphabet object
//======================================================================

//======================================================================
// start StandardAlphabet object
//======================================================================

// an extension of the alphabet object to support some additional fields 
// only present in standard alphabets.
var StandardAlphabet = function(enum_code, enum_name, alphabet_data) {
  Alphabet.apply(this, [alphabet_data]);
  this.enum_code = enum_code;
  this.enum_name = enum_name;
};
StandardAlphabet.prototype = Alphabet.prototype;
StandardAlphabet.prototype.constructor = StandardAlphabet;

// A unique code for this standard alphabet.
// This code will be a power of 2 to enable creation of bitsets for
// a selection of standard alphabets.
StandardAlphabet.prototype.get_code = function() {
  return this.enum_code;
};

// A unique name for this standard alphabet.
// this name will be all upper case and the same as the property that
// refers to this alphabet in the AlphStd collection.
StandardAlphabet.prototype.get_enum = function() {
  return this.enum_name;
};

//======================================================================
// end StandardAlphabet object
//======================================================================

// A collection of standard alphabets.
var AlphStd = {
  RNA: new StandardAlphabet(1, "RNA", {
    "name": "RNA",
    "like": "RNA",
    "ncore": 4,
    "symbols": [
      {"symbol": "A", "name": "Adenine", "colour": "CC0000"},
      {"symbol": "C", "name": "Cytosine", "colour": "0000CC"},
      {"symbol": "G", "name": "Guanine", "colour": "FFB300"},
      {"symbol": "U", "name": "Uracil", "colour": "008000",
        "aliases": "T"},
      {"symbol": "N", "name": "Any base", "equals": "ACGU", "aliases": "X."},
      {"symbol": "V", "name": "Not U", "equals": "ACG"},
      {"symbol": "H", "name": "Not G", "equals": "ACU"},
      {"symbol": "D", "name": "Not C", "equals": "AGU"},
      {"symbol": "B", "name": "Not A", "equals": "CGU"},
      {"symbol": "M", "name": "Amino", "equals": "AC"},
      {"symbol": "R", "name": "Purine", "equals": "AG"},
      {"symbol": "W", "name": "Weak", "equals": "AU"}, 
      {"symbol": "S", "name": "Strong", "equals": "CG"},
      {"symbol": "Y", "name": "Pyrimidine", "equals": "CU"},
      {"symbol": "K", "name": "Keto", "equals": "GU"}
    ]
  }), 
  DNA: new StandardAlphabet(2, "DNA", {
    "name": "DNA",
    "like": "DNA",
    "ncore": 4,
    "symbols": [
      {"symbol": "A", "name": "Adenine", "colour": "CC0000", "complement": "T"},
      {"symbol": "C", "name": "Cytosine", "colour": "0000CC", "complement": "G"},
      {"symbol": "G", "name": "Guanine", "colour": "FFB300", "complement": "C"},
      {"symbol": "T", "name": "Thymine", "colour": "008000", "complement": "A",
        "aliases": "U"},
      {"symbol": "N", "name": "Any base", "equals": "ACGT", "aliases": "X."},
      {"symbol": "V", "name": "Not T", "equals": "ACG"},
      {"symbol": "H", "name": "Not G", "equals": "ACT"},
      {"symbol": "D", "name": "Not C", "equals": "AGT"},
      {"symbol": "B", "name": "Not A", "equals": "CGT"},
      {"symbol": "M", "name": "Amino", "equals": "AC"},
      {"symbol": "R", "name": "Purine", "equals": "AG"},
      {"symbol": "W", "name": "Weak", "equals": "AT"}, 
      {"symbol": "S", "name": "Strong", "equals": "CG"},
      {"symbol": "Y", "name": "Pyrimidine", "equals": "CT"},
      {"symbol": "K", "name": "Keto", "equals": "GT"}
    ]
  }), 
  PROTEIN: new StandardAlphabet(4, "PROTEIN", {
    "name": "Protein",
    "like": "PROTEIN",
    "ncore": 20,
    "symbols": [
      {"symbol": "A", "name": "Alanine", "colour": "0000CC"},
      {"symbol": "C", "name": "Cysteine", "colour": "0000CC"},
      {"symbol": "D", "name": "Aspartic acid", "colour": "FF00FF"},
      {"symbol": "E", "name": "Glutamic acid", "colour": "FF00FF"},
      {"symbol": "F", "name": "Phenylalanine", "colour": "0000CC"},
      {"symbol": "G", "name": "Glycine", "colour": "FFB300"},
      {"symbol": "H", "name": "Histidine", "colour": "FFCCCC"},
      {"symbol": "I", "name": "Isoleucine", "colour": "0000CC"},
      {"symbol": "K", "name": "Lysine", "colour": "CC0000"},
      {"symbol": "L", "name": "Leucine", "colour": "0000CC"},
      {"symbol": "M", "name": "Methionine", "colour": "0000CC"},
      {"symbol": "N", "name": "Asparagine", "colour": "008000"},
      {"symbol": "P", "name": "Proline", "colour": "FFFF00"},
      {"symbol": "Q", "name": "Glutamine", "colour": "008000"},
      {"symbol": "R", "name": "Arginine", "colour": "CC0000"},
      {"symbol": "S", "name": "Serine", "colour": "008000"},
      {"symbol": "T", "name": "Threonine", "colour": "008000"},
      {"symbol": "V", "name": "Valine", "colour": "0000CC"},
      {"symbol": "W", "name": "Tryptophan", "colour": "0000CC"},
      {"symbol": "Y", "name": "Tyrosine", "colour": "33E6CC"},
      {"symbol": "X", "name": "Any amino acid", "equals": "ACDEFGHIKLMNPQRSTVWY", "aliases": "*."},
      {"symbol": "B", "name": "Asparagine or Aspartic acid", "equals": "DN"}, 
      {"symbol": "Z", "name": "Glutamine or Glutamic acid", "equals": "EQ"}, 
      {"symbol": "J", "name": "Leucine or Isoleucine", "equals": "IL"}
    ]
  })
};

//======================================================================
// start Symbol object
//======================================================================
var Symbol = function(alph_index, scale, alphabet) {
  "use strict";
  //variable prototype
  this.symbol = alphabet.get_symbol(alph_index);
  this.scale = scale;
  this.colour = alphabet.get_colour(alph_index);
};

Symbol.prototype.get_symbol = function() {
  "use strict";
  return this.symbol;
};

Symbol.prototype.get_scale = function() {
  "use strict";
  return this.scale;
};

Symbol.prototype.get_colour = function() {
  "use strict";
  return this.colour;
};

Symbol.prototype.toString = function() {
  "use strict";
  return this.symbol + " " + (Math.round(this.scale*1000)/10) + "%";
};

function compare_symbol(sym1, sym2) {
  "use strict";
  if (sym1.get_scale() < sym2.get_scale()) {
    return -1;
  } else if (sym1.get_scale() > sym2.get_scale()) {
    return 1;
  } else {
    return 0;
  }
}
//======================================================================
// end Symbol object
//======================================================================

//======================================================================
// start Pspm object
//======================================================================
var Pspm = function(matrix, name, ltrim, rtrim, nsites, evalue, pssm, alt) {
  "use strict";
  var row, col, data, row_sum, delta, evalue_re;
  if (typeof name !== "string") {
    name = "";
  }
  this.name = name;
  //construct
  if (matrix instanceof Pspm) {
    // copy constructor
    this.alph_length = matrix.alph_length;
    this.motif_length = matrix.motif_length;
    this.name = matrix.name;
    this.alt = matrix.alt;
    this.nsites = matrix.nsites;
    this.evalue = matrix.evalue;
    this.ltrim = matrix.ltrim;
    this.rtrim = matrix.rtrim;
    this.pspm = [];
    for (row = 0; row < matrix.motif_length; row++) {
      this.pspm[row] = [];
      for (col = 0; col < matrix.alph_length; col++) {
        this.pspm[row][col] = matrix.pspm[row][col];
      }
    }
    if (matrix.pssm != null) {
      this.pssm = [];
      for (row = 0; row < matrix.motif_length; row++) {
        this.pspm[row] = [];
        for (col = 0; col < matrix.alph_length; col++) {
          this.pssm[row][col] = matrix.pssm[row][col];
        }
      }
    }
  } else {
    // check parameters
    if (ltrim == null) {
      ltrim = 0;
    } else if (typeof ltrim !== "number" || ltrim % 1 !== 0 || ltrim < 0) {
      throw new Error("ltrim must be a non-negative integer, got: " + ltrim);
    }
    if (rtrim == null) {
      rtrim = 0;
    } else if (typeof rtrim !== "number" || rtrim % 1 !== 0 || rtrim < 0) {
      throw new Error("rtrim must be a non-negative integer, got: " + rtrim);
    }
    if (nsites != null) {
      if (typeof nsites !== "number" || nsites < 0) {
        throw new Error("nsites must be a positive number, got: " + nsites);
      } else if (nsites == 0) {
        nsites = null;
      }
    }
    if (evalue != null) {
      if (typeof evalue === "number") {
        if (evalue < 0) {
          throw new Error("evalue must be a non-negative number, got: " + evalue);
        }
      } else if (typeof evalue === "string") {
        evalue_re = /^((?:[+]?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?)|inf)$/;
        if (!evalue_re.test(evalue)) {
          throw new Error("evalue must be a non-negative number, got: " + evalue);
        }
      } else {
        throw new Error("evalue must be a non-negative number, got: " + evalue);
      }
    }
    // set properties
    this.name = name;
    this.alt = alt;
    this.nsites = nsites;
    this.evalue = evalue;
    this.ltrim = ltrim;
    this.rtrim = rtrim;
    if (typeof matrix === "string") {
      // string constructor
      data = parse_pspm_string(matrix);
      this.alph_length = data["alph_length"];
      this.motif_length = data["motif_length"];
      this.pspm = data["pspm"];
      if (this.evalue == null) {
        if (data["evalue"] != null) {
          this.evalue = data["evalue"];
        } else {
          this.evalue = 0;
        }
      }
      if (this.nsites == null) {
        if (typeof data["nsites"] === "number") {
          this.nsites = data["nsites"];
        } else {
          this.nsites = 20;
        }
      }
    } else {
      // assume pspm is a nested array
      this.motif_length = matrix.length;
      this.alph_length = (matrix.length > 0 ? matrix[0].length : 0);
      if (this.nsites == null) {
        this.nsites = 20;
      }
      if (this.evalue == null) {
        this.evalue = 0;
      }
      this.pspm = [];
      // copy pspm and check
      for (row = 0; row < this.motif_length; row++) {
        if (this.alph_length != matrix[row].length) {
          throw new Error("COLUMN_MISMATCH");
        }
        this.pspm[row] = [];
        row_sum = 0;
        for (col = 0; col < this.alph_length; col++) {
          this.pspm[row][col] = matrix[row][col];
          row_sum += this.pspm[row][col];
        }
        delta = 0.1;
        if (isNaN(row_sum) || (row_sum > 1 && (row_sum - 1) > delta) || 
            (row_sum < 1 && (1 - row_sum) > delta)) {
          throw new Error("INVALID_SUM");
        }
      }
      // copy pssm
      if (pssm != null) {
        this.pssm = [];
        for (row = 0; row < this.motif_length; row++) {
          this.pssm[row] = [];
          for (col = 0; col < this.alph_length; col++) {
            this.pssm[row][col] = pssm[row][col];
          }
        }
      }
    }
  }
};

Pspm.prototype.copy = function() {
  "use strict";
  return new Pspm(this);
};

Pspm.prototype.reverse = function() {
  "use strict";
  var x, y, temp, temp_trim;
  //reverse
  x = 0;
  y = this.motif_length-1;
  while (x < y) {
    temp = this.pspm[x];
    this.pspm[x] = this.pspm[y];
    this.pspm[y] = temp;
    x++;
    y--;
  }
  // reverse pssm (if defined)
  if (typeof this.pssm !== "undefined") {
    //reverse
    x = 0;
    y = this.motif_length-1;
    while (x < y) {
      temp = this.pssm[x];
      this.pspm[x] = this.pssm[y];
      this.pssm[y] = temp;
      x++;
      y--;
    }
  }
  //swap triming
  temp_trim = this.ltrim;
  this.ltrim = this.rtrim;
  this.rtrim = temp_trim;
  return this; //allow function chaining...
};

Pspm.prototype.reverse_complement = function(alphabet) {
  "use strict";
  var x, y, temp, i, row, c, temp_trim;
  if (this.alph_length != alphabet.get_size_core()) {
    throw new Error("The alphabet size does not match the size of the pspm.");
  }
  if (!alphabet.has_complement()) {
    throw new Error("The specified alphabet can not be complemented.");
  }
  // reverse motif
  this.reverse();
  //complement
  for (x = 0; x < this.motif_length; x++) {
    row = this.pspm[x];
    for (i = 0; i < row.length; i++) {
      c = alphabet.get_complement(i);
      if (c < i) continue;
      temp = row[i];
      row[i] = row[c];
      row[c] = temp;
    }
  }
  // complement pssm (if defined)
  if (typeof this.pssm !== "undefined") {
    //complement
    for (x = 0; x < this.motif_length; x++) {
      row = this.pssm[x];
      for (i = 0; i < row.length; i++) {
        c = alphabet.get_complement(i);
        if (c < i) continue;
        temp = row[i];
        row[i] = row[c];
        row[c] = temp;
      }
    }
  }
  return this; //allow function chaining...
};

Pspm.prototype.get_stack = function(position, alphabet, ssc) {
  "use strict";
  var row, stack_ic, alphabet_ic, stack, i, sym;
  if (this.alph_length != alphabet.get_size_core()) {
    throw new Error("The alphabet size does not match the size of the pspm.");
  }
  row = this.pspm[position];
  stack_ic = this.get_stack_ic(position, alphabet);
  if (ssc) stack_ic -= this.get_error(alphabet);
  alphabet_ic = alphabet.get_ic();
  stack = [];
  for (i = 0; i < this.alph_length; i++) {
    sym = new Symbol(i, row[i]*stack_ic/alphabet_ic, alphabet);
    if (sym.get_scale() <= 0) {
      continue;
    }
    stack.push(sym);
  }
  stack.sort(compare_symbol);
  return stack;
};

Pspm.prototype.get_stack_ic = function(position, alphabet) {
  "use strict";
  var row, H, i;
  if (this.alph_length != alphabet.get_size_core()) {
    throw new Error("The alphabet size does not match the size fo the pspm.");
  }
  row = this.pspm[position];
  H = 0;
  for (i = 0; i < this.alph_length; i++) {
    if (row[i] === 0) {
      continue;
    }
    H -= (row[i] * (Math.log(row[i]) / Math.LN2));
  }
  return alphabet.get_ic() - H;
};

Pspm.prototype.get_error = function(alphabet) {
  "use strict";
  if (this.nsites === 0) {
    return 0;
  }
  return (alphabet.get_size_core()-1) / (2 * Math.LN2 * this.nsites);
};

Pspm.prototype.get_motif_length = function() {
  "use strict";
  return this.motif_length;
};

Pspm.prototype.get_alph_length = function() {
  "use strict";
  return this.alph_length;
};

Pspm.prototype.get_left_trim = function() {
  "use strict";
  return this.ltrim;
};

Pspm.prototype.get_right_trim = function() {
  "use strict";
  return this.rtrim;
};

Pspm.prototype.as_best_match = function(alphabet) {
  "use strict";
  var match, odds, best_odds, best_index;
  var i, j;
  match = "";
  for (i = 0; i < this.motif_length; i++) {
    best_index = 0;
    best_odds = this.pspm[i][0] / alphabet.get_bg_freq(0);
    for (j = 1; j < this.alph_length; j++) {
      odds = this.pspm[i][j] / alphabet.get_bg_freq(j);
      if (odds > best_odds) {
        best_odds = odds;
        best_index = j;
      }
    }
    match += alphabet.get_symbol(best_index);
  }
  return match;
};

Pspm.prototype.as_count_matrix = function() {
  "use strict";
  var count, count_text, text;
  var i, j;
  text = "";
  for (i = 0; i < this.motif_length; i++) {
    if (i !== 0) {
      text += "\n";
    }
    for (j = 0; j < this.alph_length; j++) {
      if (j !== 0) {
        text += " ";
      }
      count = Math.round(this.nsites * this.pspm[i][j]);
      count_text = "" + count;
      // pad up to length of 4
      if (count_text.length < 4) {
        text += (new Array(5 - count_text.length)).join(" ") + count_text;
      } else {
        text += count_text;
      }
    }
  }
  return text; 
};

Pspm.prototype.as_probability_matrix = function() {
  "use strict";
  var text;
  var i, j;
  text = "";
  for (i = 0; i < this.motif_length; i++) {
    if (i !== 0) {
      text += "\n";
    }
    for (j = 0; j < this.alph_length; j++) {
      if (j !== 0) {
        text += " ";
      }
      text += this.pspm[i][j].toFixed(6);
    }
  }
  return text; 
};

Pspm.prototype.as_score_matrix = function(alphabet, pseudo) {
  "use strict";
  var me, score, out, row, col, score_text;
  me = this;
  if (typeof this.pssm === "undefined") {
    if (!(typeof alphabet === "object" && alphabet != null && alphabet instanceof Alphabet)) {
      throw new Error("The alphabet is required to generate the pssm.");
    }
    if (typeof pseudo === "undefined") {
      pseudo = 0.01;
    } else if (typeof pseudo !== "number" || pseudo < 0) {
      throw new Error("Expected positive number for pseudocount");
    }
    score = function(row, col) {
      "use strict";
      var p, bg, p2;
      p = me.pspm[row][col];
      bg = alphabet.get_bg_freq(col);
      p2 = (p * me.nsites + bg * pseudo) / (me.nsites + pseudo);
      return (p2 > 0 ? Math.round((Math.log(p2 / bg) / Math.LN2) * 100) : -10000);
    };
  } else {
    score = function(row, col) {
      "use strict";
      return me.pssm[row][col];
    };
  }
  out = "";
  for (row = 0; row < this.motif_length; row++) {
    for (col = 0; col < this.alph_length; col++) {
      if (col !== 0) {
        out += " ";
      }
      score_text = "" + score(row, col);
      // pad out to 6 characters
      if (score_text.length < 6) {
        out += (new Array(7 - score_text.length)).join(" ") + score_text;
      } else {
        out += score_text;
      }
    }
    out += "\n";
  }
  return out;
}

Pspm.prototype.as_pspm = function() {
  "use strict";
  return "letter-probability matrix: alength= " + this.alph_length + 
      " w= " + this.motif_length + " nsites= " + this.nsites + 
      " E= " + (typeof this.evalue === "number" ? 
          this.evalue.toExponential() : this.evalue) + "\n" +
      this.as_probability_matrix();
};

Pspm.prototype.as_pssm = function(alphabet, pseudo) {
  "use strict";
  return "log-odds matrix: alength= " + this.alph_length + 
      " w= " + this.motif_length + 
      " E= " + (typeof this.evalue == "number" ?
          this.evalue.toExponential() : this.evalue) + "\n" +
      this.as_score_matrix(alphabet, pseudo);
};

Pspm.prototype.as_meme = function(options) {
  var with_header, with_pspm, with_pssm, version, alphabet, bg_source, pseudocount, strands;
  var out, alen, i;
  // get the options
  if (typeof options !== "object" || options === null) {
    options = {};
  }
  with_header = (typeof options["with_header"] === "boolean" ? options["with_header"] : false);
  with_pspm = (typeof options["with_pspm"] === "boolean" ? options["with_pspm"] : false);
  with_pssm = (typeof options["with_pssm"] === "boolean" ? options["with_pssm"] : false);
  if (!with_pspm && !with_pssm) with_pspm = true;
  if (with_header) {
    if (typeof options["version"] === "string" && /^\d+(?:\.\d+){0,2}$/.test(options["version"])) {
      version = options["version"];
    } else if (typeof options["version"] === "number") {
      version = options["version"].toFixed(0);
    } else {
      version = "4";
    }
    if (typeof options["strands"] === "number" && options["strands"] === 1) {
      strands = 1;
    } else {
      strands = 2;
    }
    if (typeof options["bg_source"] === "string") {
      bg_source = options["bg_source"];
    } else {
      bg_source = "unknown source";
    }
    if (typeof options["alphabet"] === "object" && options["alphabet"] != null
        && options["alphabet"] instanceof Alphabet) {
      alphabet = options["alphabet"];
    } else {
      throw new Error("The alphabet is required to generate the header.");
    }
  }
  // now create the output
  out = "";
  if (with_header) {
    out = "MEME version " + version + "\n\n";
    out += alphabet.as_meme() + "\n";
    if (alphabet.has_complement()) { // assume DNA has both strands unless otherwise specified
      out += "strands: " + (strands === 1 ? "+" : "+ -") + "\n\n";
    }
    out += "Background letter frequencies (from " + bg_source + "):\n";
    alen = alphabet.get_size_core();
    for (i = 0; i < alen; i++) {
      if (i !== 0) {
        if (i % 9 === 0) { // maximum of nine entries per line
          out += "\n";
        } else {
          out += " ";
        }
      }
      out += alphabet.get_symbol(i) + " " + alphabet.get_bg_freq(i).toFixed(3);
    }
  }
  out += "\n\n";
  out += "MOTIF " + this.name + (this.alt == null ? "" : " " + this.alt);
  if (with_pssm) {
    out += "\n\n";
    out += this.as_pssm(options["alphabet"], options["pseudocount"]);
  }
  if (with_pspm) {
    out += "\n\n";
    out += this.as_pspm();
  }
  return out;
}

Pspm.prototype.toString = function() {
  "use strict";
  var str, i, row;
  str = "";
  for (i = 0; i < this.pspm.length; i++) {
    row = this.pspm[i];
    str += row.join("\t") + "\n";
  }
  return str;
};

function parse_pspm_properties(str) {
  "use strict";
  var parts, i, eqpos, before, after, properties, prop, num, num_re;
  num_re = /^((?:[+]?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?)|inf)$/;
  parts = trim(str).split(/\s+/);
  // split up words containing =
  for (i = 0; i < parts.length;) {
    eqpos = parts[i].indexOf("=");
    if (eqpos != -1) {
      before = parts[i].substr(0, eqpos);
      after = parts[i].substr(eqpos+1);
      if (before.length > 0 && after.length > 0) {
        parts.splice(i, 1, before, "=", after);
        i += 3;
      } else if (before.length > 0) {
        parts.splice(i, 1, before, "=");
        i += 2;
      } else if (after.length > 0) {
        parts.splice(i, 1, "=", after);
        i += 2;
      } else {
        parts.splice(i, 1, "=");
        i++;
      }
    } else {
      i++;
    }
  }
  properties = {};
  for (i = 0; i < parts.length; i += 3) {
    if (parts.length - i < 3) {
      throw new Error("Expected PSPM property was incomplete. "+
          "Remaing parts are: " + parts.slice(i).join(" "));
    }
    if (parts[i+1] !== "=") {
      throw new Error("Expected '=' in PSPM property between key and " +
          "value but got " + parts[i+1]); 
    }
    prop = parts[i].toLowerCase();
    num = parts[i+2];
    if (!num_re.test(num)) {
      throw new Error("Expected numeric value for PSPM property '" + 
          prop + "' but got '" + num + "'");
    }
    properties[prop] = num;
  }
  return properties;
}

function parse_pspm_string(pspm_string) {
  "use strict";
  var header_re, lines, first_line, line_num, col_num, alph_length, 
      motif_length, nsites, evalue, pspm, i, line, match, props, parts,
      j, prob;
  header_re = /^letter-probability\s+matrix:(.*)$/i;
  lines = pspm_string.split(/\n/);
  first_line = true;
  line_num = 0;
  col_num = 0;
  alph_length;
  motif_length;
  nsites;
  evalue;
  pspm = [];
  for (i = 0; i < lines.length; i++) {
    line = trim(lines[i]);
    if (line.length === 0) { 
      continue;
    }
    // check the first line for a header though allow matrices without it
    if (first_line) {
      first_line = false;
      match = header_re.exec(line);
      if (match !== null) {
        props = parse_pspm_properties(match[1]);
        if (props.hasOwnProperty("alength")) {
          alph_length = parseFloat(props["alength"]);
          if (alph_length != 4 && alph_length != 20) {
            throw new Error("PSPM property alength should be 4 or 20" +
                " but got " + alph_length);
          }
        }
        if (props.hasOwnProperty("w")) {
          motif_length = parseFloat(props["w"]);
          if (motif_length % 1 !== 0 || motif_length < 1) {
            throw new Error("PSPM property w should be an integer larger " +
                "than zero but got " + motif_length);
          }
        }
        if (props.hasOwnProperty("nsites")) {
          nsites = parseFloat(props["nsites"]);
          if (nsites <= 0) {
            throw new Error("PSPM property nsites should be larger than " +
                "zero but got " + nsites);
          }
        }
        if (props.hasOwnProperty("e")) {
          evalue = props["e"];
          if (evalue < 0) {
            throw new Error("PSPM property evalue should be " +
                "non-negative but got " + evalue);
          }
        }
        continue;
      }
    }
    pspm[line_num] = [];
    col_num = 0;
    parts = line.split(/\s+/);
    for (j = 0; j < parts.length; j++) {
      prob = parseFloat(parts[j]);
      if (prob != parts[j] || prob < 0 || prob > 1) {
        throw new Error("Expected probability but got '" + parts[j] + "'"); 
      }
      pspm[line_num][col_num] = prob;
      col_num++;
    }
    line_num++;
  }
  if (typeof motif_length === "number") {
    if (pspm.length != motif_length) {
      throw new Error("Expected PSPM to have a motif length of " + 
          motif_length + " but it was actually " + pspm.length);
    }
  } else {
    motif_length = pspm.length;
  }
  if (typeof alph_length !== "number") {
    alph_length = pspm[0].length;
    if (alph_length != 4 && alph_length != 20) {
      throw new Error("Expected length of first row in the PSPM to be " +
          "either 4 or 20 but got " + alph_length);
    }
  }
  for (i = 0; i < pspm.length; i++) {
    if (pspm[i].length != alph_length) {
      throw new Error("Expected PSPM row " + i + " to have a length of " + 
          alph_length + " but the length was " + pspm[i].length);
    }
  }
  return {"pspm": pspm, "motif_length": motif_length, 
    "alph_length": alph_length, "nsites": nsites, "evalue": evalue};
}
//======================================================================
// end Pspm object
//======================================================================

//======================================================================
// start Logo object
//======================================================================

var Logo = function(alphabet, options) {
  "use strict";
  this.alphabet = alphabet;
  this.fine_text = "";
  this.x_axis = 1;
  this.y_axis = true;
  this.xlate_nsyms = 1;
  this.xlate_start = null;
  this.xlate_end = null;
  this.pspm_list = [];
  this.pspm_column = [];
  this.rows = 0;
  this.columns = 0;
  if (typeof options === "string") {
    // the old method signature had fine_text here so we support that
    this.fine_text = options;
  } else if (typeof options === "object" && options != null) {
    this.fine_text = (typeof options.fine_text === "string" ? options.fine_text : "");
    this.x_axis = (typeof options.x_axis === "boolean" ? (options.x_axis ? 1 : 0) : 1);
    if (options.x_axis_hidden != null && options.x_axis_hidden) this.x_axis = -1;
    this.y_axis = (typeof options.y_axis === "boolean" ? options.y_axis : true);
    this.xlate_nsyms = (typeof options.xlate_nsyms === "number" ? options.xlate_nsyms : this.xlate_nsyms);
    this.xlate_start = (typeof options.xlate_start === "number" ? options.xlate_start : this.xlate_start);
    this.xlate_end = (typeof options.xlate_end === "number" ? options.xlate_end : this.xlate_end);
  }
};

Logo.prototype.add_pspm = function(pspm, column) {
  "use strict";
  var col;
  if (typeof column === "undefined") {
    column = 0;
  } else if (column < 0) {
    throw new Error("Column index out of bounds.");
  }
  this.pspm_list[this.rows] = pspm;
  this.pspm_column[this.rows] = column;
  this.rows++;
  col = column + pspm.get_motif_length();
  if (col > this.columns) {
    this.columns = col;
  }
};

Logo.prototype.get_columns = function() {
  "use strict";
  return this.columns;
};

Logo.prototype.get_xlate_nsyms = function() {
  "use strict";
  return this.xlate_nsyms;
};

Logo.prototype.get_xlate_start = function() {
  "use strict";
  return (this.xlate_start != null ? this.xlate_start : 0);
};

Logo.prototype.get_xlate_end = function() {
  "use strict";
  return (this.xlate_end != null ? this.xlate_end : this.columns * this.xlate_nsyms);
};

Logo.prototype.get_xlate_columns = function() {
  "use strict";
  return this.get_xlate_end() - this.get_xlate_start();
};

Logo.prototype.get_rows = function() {
  "use strict";
  return this.rows;
};

Logo.prototype.get_pspm = function(row_index) {
  "use strict";
  if (row_index < 0 || row_index >= this.rows) {
    throw new Error("INDEX_OUT_OF_BOUNDS");
  }
  return this.pspm_list[row_index];
};

Logo.prototype.get_offset = function(row_index) {
  "use strict";
  if (row_index < 0 || row_index >= this.rows) {
    throw new Error("INDEX_OUT_OF_BOUNDS");
  }
  return this.pspm_column[row_index];
};

Logo.prototype._as_eps_data = function(ssc, errbars) {
  var i, j, pos, stack_pos, pspm, stack, sym, out;
  out = "";
  for (i = 0; i < this.rows; i++) {
    out += "\nStartLine\n";
    // Indent
    for (j = 0; j < this.pspm_column[i]; j++) {
      out += "() startstack\nendstack\n\n";
    }
    pspm = this.pspm_list[i];
    if (pspm.get_left_trim() > 0) {
      out += "MuteColour\nDrawTrimEdge\n" + pspm.get_left_trim() + " DrawTrimBg\n";
    }
    for (pos = 0; pos < pspm.get_motif_length(); pos++) {
      if (pos != 0 && pos == pspm.get_left_trim()) { // enable full colour
        out += "DrawTrimEdge\nRestoreColour\n";
      } else if (pos == (pspm.get_motif_length() - pspm.get_right_trim())) {
        out += "MuteColour\n" + pspm.get_right_trim() + " DrawTrimBg\n";
      }
      out += "(" + (pos + 1) + ") startstack\n";
      stack = pspm.get_stack(pos, this.alphabet, ssc);
      for (stack_pos = 0; stack_pos < stack.length; stack_pos++) {
        sym = stack[stack_pos];
        out += " " + (sym.get_scale() * this.alphabet.get_ic()) + " (" + sym.get_symbol() + ") numchar\n";
      }
      if (errbars) {
        out += " " + pspm.get_error(this.alphabet) + " Ibeam\n";
      }
      out += "endstack\n\n";
    }
    if (pspm.get_right_trim() > 0 || pspm.get_left_trim() == pspm.get_motif_length()) {
      out += "RestoreColour\n";
    }
    out += "EndLine\n";
  }
  return out;
};

Logo.prototype.as_eps = function(options) {
  "use strict";
  if (this.xlate_nsyms != 1) throw new Error("Unsupported setting xlate_nsyms for EPS");
  if (this.xlate_start != null) throw new Error("Unsupported setting xlate_start for EPS");
  if (this.xlate_end != null) throw new Error("Unsupported setting xlate_end for EPS");

  var LOGOHEIGHT = 7.5; // default height of line in cm
  var cm2pts, height, width, now, ssc, errbars;
  if (typeof options === "undefined") {
    options = {};
  }
  cm2pts = 72 / 2.54;
  if (typeof options.logo_height == "number") {
    height = options.logo_height;
  } else {
    height = LOGOHEIGHT * this.rows;
  }
  if (typeof options.logo_width == "number") {
    width = options.logo_width;
  } else {
    width = this.columns + 2;
  }
  now = new Date();
  ssc = (typeof options.ssc == "boolean" ? options.ssc : false);
  errbars = (typeof options.show_error_bar == "boolean" ? options.show_error_bar : ssc);
  var values = {
    "LOGOHEIGHT": height,
    "LOGOWIDTH": width,
    "BOUNDINGHEIGHT": Math.round(height * cm2pts),
    "BOUNDINGWIDTH": Math.round(width * cm2pts),
    "LOGOLINEHEIGHT": (height / this.rows),
    "CHARSPERLINE": this.columns,
    "BARBITS": this.alphabet.get_ic(),
    "LOGOTYPE": (this.alphabet.has_complement() ? "NA" : "AA"),
    "CREATIONDATE": now.getDate() + "." + (now.getMonth() + 1) + "." + now.getFullYear() + " " + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds(),
    "ERRORBARFRACTION": (typeof options.error_bar_fraction == "number" ? options.error_bar_fraction : 1.0),
    "TICBITS": (typeof options.ticbits == "number" ? options.ticbits : 1.0),
    "TITLE": (typeof options.title == "string" ? options.title : ""),
    "FINEPRINT": (typeof options.fineprint == "string" ? options.fineprint : this.fine_text),
    "XAXISLABEL": (typeof options.xaxislabel == "string" ? options.xaxislabel : ""),
    "YAXISLABEL": (typeof options.yaxislabel == "string" ? options.yaxislabel : "bits"),
    "SSC": ssc,
    "YAXIS": (typeof options.show_y_axis == "boolean" ? options.show_y_axis : this.y_axis),
    "SHOWENDS": (typeof options.show_ends == "boolean" ? options.show_ends : false),
    "ERRBAR": errbars,
    "OUTLINE": (typeof options.show_outline == "boolean" ? options.show_outline : false),
    "NUMBERING": (typeof options.show_numbering == "boolean" ? options.show_numbering : this.x_axis != 0),
    "SHOWINGBOX": (typeof options.show_box == "boolean" ? options.show_box : false),
    "CREATOR": (typeof options.creator == "string" ? options.creator : "motif_logo.js"),
    "FONTSIZE": (typeof options.label_font_size == "number" ? options.label_font_size : 12),
    "TITLEFONTSIZE": (typeof options.title_font_size == "number" ? options.title_font_size : 12),
    "SMALLFONTSIZE": (typeof options.small_font_size == "number" ? options.small_font_size : 6),
    "TOPMARGIN" : (typeof options.top_margin == "number" ? options.top_margin : 0.9),
    "BOTTOMMARGIN": (typeof options.bottom_margin == "number" ? options.bottom_margin : 0.9),
    "COLORDICT": this.alphabet._as_eps_dict(),
    "DATA": this._as_eps_data(ssc, errbars)
  };
  // now this requires that the script containing the template has been imported!
  return motif_logo_template(values);
};

//======================================================================
// end Logo object
//======================================================================

// calculate the exact size (in pixels) of an object drawn on the
// canvas assuming that the background of the canvas is transparent.
function canvas_bounds(ctx, cwidth, cheight) {
  "use strict";
  var data, r, c, top_line, bottom_line, left_line, right_line, 
      txt_width, txt_height;

  // extract the image data
  data = ctx.getImageData(0, 0, cwidth, cheight).data;

  // set initial values
  top_line = -1; bottom_line = -1; left_line = -1; right_line = -1;
  txt_width = 0; txt_height = 0;

  // Find the top-most line with a non-transparent pixel
  for (r = 0; r < cheight; r++) {
    for (c = 0; c < cwidth; c++) {
      if (data[r * cwidth * 4 + c * 4 + 3]) {
        top_line = r;
        break;
      }
    }
    if (top_line != -1) {
      break;
    }
  }
  
  // Only bother looking if we found at least one set pixel... 
  if (top_line != -1) {

    //find the last line with a non-transparent pixel
    for (r = cheight-1; r >= top_line; r--) {
      for(c = 0; c < cwidth; c++) {
        if(data[r * cwidth * 4 + c * 4 + 3]) {
          bottom_line = r;
          break;
        }
      }
      if (bottom_line != -1) {
        break;
      }
    }
    // calculate height
    txt_height = bottom_line - top_line + 1;

    // Find the left-most line with a non-transparent pixel
    for (c = 0; c < cwidth; c++) {
      for (r = top_line; r <= bottom_line; r++) {
        if (data[r * cwidth * 4 + c * 4 + 3]) {
          left_line = c;
          break;
        }
      }
      if (left_line != -1) {
        break;
      }
    }

    //find the right most line with a non-transparent pixel
    for (c = cwidth-1; c >= left_line; c--) {
      for(r = top_line; r <= bottom_line; r++) {
        if(data[r * cwidth * 4 + c * 4 + 3]) {
          right_line = c;
          break;
        }
      }
      if (right_line != -1) {
        break;
      }
    }
    txt_width = right_line - left_line + 1;
  }

  //return the bounds
  return {bound_top: top_line, bound_bottom: bottom_line, 
    bound_left: left_line, bound_right: right_line, width: txt_width, 
    height: txt_height};
}

//======================================================================
// start RasterizedAlphabet
//======================================================================

// Rasterize Alphabet
// 1) Measure width of text at default font for all symbols in alphabet
// 2) sort in width ascending
// 3) Drop the top and bottom 10% (designed to ignore outliers like 'W' and 'I')
// 4) Calculate the average as the maximum scaling factor (designed to stop I becoming a rectangular blob).
// 5) Assume scale of zero would result in width of zero, interpolate scale required to make perfect width font
// 6) Draw text onto temp canvas at calculated scale
// 7) Find bounds of drawn text
// 8) Paint on to another canvas at the desired height (but only scaling width to fit if larger).
var RasterizedAlphabet = function(alphabet, logo_scale, font, width) {
  "use strict";
  var default_size, safety_pad, canvas, ctx, middle, baseline, widths, sizes,
      i, sym, size, tenpercent, avg_width, scale, 
      target_width, target_height;
  //variable prototypes
  this.alphabet = alphabet;
  this.scale = logo_scale;
  this.sym_cache = {};
  this.stack_num_cache = [];
  this.scale_num_cache = [];
  // size of canvas
  default_size = 60; // size of measuring canvas
  safety_pad = 20; // pixels to pad around so we don't miss the edges
  // create a canvas to do our measuring
  canvas = document.createElement("canvas");
  if (!canvas.getContext) throw new Error("No canvas support");
  canvas.width = default_size + 2 * safety_pad;
  canvas.height = default_size + 2 * safety_pad;
  middle = Math.round(canvas.width / 2);
  baseline = Math.round(canvas.height - safety_pad);
  ctx = canvas.getContext('2d');
  if (!supports_text(ctx)) throw new Error("Canvas does not support text");
  ctx.font = font;
  ctx.textAlign = "center";
  ctx.translate(middle, baseline);
  // list of widths
  widths = [];
  sizes = [];
  //now measure each letter in the alphabet
  for (i = 0; i < alphabet.get_size_core(); ++i) {
    // reset the canvas
    ctx.clearRect(0, 0, canvas.width, canvas.height);
    ctx.fillStyle = alphabet.get_colour(i);
    // draw the test text
    ctx.fillText(alphabet.get_symbol(i), 0, 0);
    //measure
    size = canvas_bounds(ctx, canvas.width, canvas.height);
    if (size.width === 0) throw new Error("Invisible symbol!");
    widths.push(size.width);
    sizes[i] = size;
  }
  //sort the widths
  widths.sort(function(a,b) {return a - b;});
  //drop 10% of the items off each end
  tenpercent = Math.floor(widths.length / 10);
  for (i = 0; i < tenpercent; ++i) {
    widths.pop();
    widths.shift();
  }
  //calculate average width
  avg_width = 0;
  for (i = 0; i < widths.length; ++i) {
    avg_width += widths[i];
  }
  avg_width /= widths.length;
  // calculate the target width
  target_width = width * this.scale * 2;
  // calculate scales
  for (i = 0; i < alphabet.get_size_core(); ++i) {
    sym = alphabet.get_symbol(i);
    size = sizes[i];
    // calculate scale
    scale = target_width / Math.max(avg_width, size.width);
    // estimate scaled height
    target_height = size.height * scale;
    // create an appropriately sized canvas
    canvas = document.createElement("canvas");
    canvas.width = target_width;
    canvas.height = target_height + safety_pad * 2;
    // calculate the middle
    middle = Math.round(canvas.width / 2);
    // calculate the baseline
    baseline = Math.round(canvas.height - safety_pad);
    // get the context and prepare to draw the rasterized text
    ctx = canvas.getContext('2d');
    ctx.font = font;
    ctx.fillStyle = alphabet.get_colour(i);
    ctx.textAlign = "center";
    ctx.translate(middle, baseline);
    ctx.save();
    ctx.scale(scale, scale);
    // draw the text
    ctx.fillText(sym, 0, 0);
    ctx.restore();
    this.sym_cache[sym] = {"image": canvas, "size": canvas_bounds(ctx, canvas.width, canvas.height)};
  }
};

RasterizedAlphabet.prototype.get_alphabet = function() {
  return this.alphabet;
};

RasterizedAlphabet.prototype.get_scale = function() {
  return this.scale;
};

RasterizedAlphabet.prototype.draw_stack_sym = function(ctx, letter, dx, dy, dWidth, dHeight) {
  "use strict";
  var entry, image, size;
  entry = this.sym_cache[letter];
  image = entry.image;
  size = entry.size;
  ctx.drawImage(image, 0, size.bound_top -1, image.width, size.height+1, dx, dy, dWidth, dHeight);
};

RasterizedAlphabet.prototype.draw_stack_num = function(ctx, font, stack_width, index) {
  var image, image_ctx, text_length;
  if (index >= this.stack_num_cache.length) {
    image = document.createElement("canvas");
    // measure the text
    image_ctx = image.getContext('2d');
    image_ctx.save();
    image_ctx.font = font;
    text_length = image_ctx.measureText("" + (index + 1)).width;
    image_ctx.restore();
    // resize the canvas to fit
    image.width = Math.ceil(stack_width);
    image.height = Math.ceil(text_length);
    // draw the text
    image_ctx = image.getContext('2d');
    image_ctx.translate(Math.round(stack_width / 2), 0);
    image_ctx.font = font;
    image_ctx.textBaseline = "middle";
    image_ctx.textAlign = "right";
    image_ctx.rotate(-(Math.PI / 2));
    image_ctx.fillText("" + (index + 1), 0, 0);
    this.stack_num_cache[index] = image;
  } else {
    image = this.stack_num_cache[index];
  }
  ctx.drawImage(image, 0, 0);
}

RasterizedAlphabet.prototype.draw_scale_num = function(ctx, font, num) {
  var image, image_ctx, text_size, m_length;
  if (num >= this.scale_num_cache.length) {
    image = document.createElement("canvas");
    // measure the text
    image_ctx = image.getContext('2d');
    image_ctx.font = font;
    text_size = image_ctx.measureText("" + num);
    if (text_size.actualBoundingBoxAscent && text_size.actualBoundingBoxDesent) {
      // resize the canvas to fit
      image.width = Math.ceil(text_size.width);
      image.height = Math.ceil(text_size.actualBoundingBoxAscent + text_size.actualBoundingBoxDesent);
      // draw the text
      image_ctx = image.getContext('2d');
      image_ctx.font = font;
      image_ctx.textAlign = "right";
      image_ctx.fillText("" + num, image.width, text_size.actualBoundingBoxAscent);
    } else {
      // measure width of 'm' to approximate height, we double it later anyway
      m_length = image_ctx.measureText("m").width;
      // resize the canvas to fit
      image.width = Math.ceil(text_size.width);
      image.height = Math.ceil(2 * m_length);
      // draw the text
      image_ctx = image.getContext('2d');
      image_ctx.font = font;
      image_ctx.textAlign = "right";
      image_ctx.textBaseline = "middle";
      image_ctx.fillText("" + num, image.width, m_length);
    }
    this.scale_num_cache[num] = image;
  } else {
    image = this.scale_num_cache[num];
  }
  ctx.drawImage(image, -image.width, -Math.round(image.height / 2))
}

//======================================================================
// end RasterizedAlphabet
//======================================================================

//======================================================================
// start LogoMetrics object
//======================================================================

var LogoMetrics = function(ctx, logo_columns, logo_rows, has_names, has_finetext, x_axis, y_axis) {
  "use strict";
  var i, row_height;
  //variable prototypes
  this.pad_top = (has_names ? 5 : 0);
  this.pad_left = (y_axis ? 10 : 0);
  this.pad_right = (has_finetext ? 15 : 0);
  this.pad_bottom = 0;
  this.pad_middle = 20;
  this.name_height = 14;
  this.name_font = "bold " + this.name_height + "px Times, sans-serif";
  this.name_spacer = 0;
  this.y_axis = y_axis;
  this.y_label = "bits";
  this.y_label_height = 12;
  this.y_label_font = "bold " + this.y_label_height + "px Helvetica, sans-serif";
  this.y_label_spacer = 3;
  this.y_num_height = 12;
  this.y_num_width = 0;
  this.y_num_font = "bold " + this.y_num_height + "px Helvetica, sans-serif";
  this.y_tic_width = 5;
  this.stack_pad_left = 0;
  this.stack_font = "bold 25px Helvetica, sans-serif";
  this.stack_height = 90;
  this.stack_width = 26;
  this.stacks_pad_right = 5;
  this.x_axis = x_axis;
  this.x_num_above = 2;
  this.x_num_height = 12;
  this.x_num_width = 0;
  this.x_num_font = "bold " + this.x_num_height + "px Helvetica, sans-serif";
  this.fine_txt_height = 6;
  this.fine_txt_above = 2;
  this.fine_txt_font = "normal " + this.fine_txt_height + "px Helvetica, sans-serif";
  this.letter_metrics = new Array();
  this.summed_width = 0;
  this.summed_height = 0;
  //calculate the width of the y axis numbers
  ctx.font = this.y_num_font;
  for (i = 0; i <= 2; i++) {
    this.y_num_width = Math.max(this.y_num_width, ctx.measureText("" + i).width);
  }
  //calculate the width of the x axis numbers (but they are rotated so it becomes height)
  if (x_axis == 1) {
    ctx.font = this.x_num_font;
    for (i = 1; i <= logo_columns; i++) {
      this.x_num_width = Math.max(this.x_num_width, ctx.measureText("" + i).width);
    }
  } else if (x_axis == 0) {
    this.x_num_height = 4;
    this.x_num_width = 4;
  } else {
    this.x_num_height = 0;
    this.x_num_width = 0;
  }
  
  //calculate how much vertical space we want to draw this
  //first we add the padding at the top and bottom since that's always there
  this.summed_height += this.pad_top + this.pad_bottom;
  //all except the last row have the same amount of space allocated to them
  if (logo_rows > 1) {
    row_height = this.stack_height + this.pad_middle;
    if (has_names) {
      row_height += this.name_height;
      //the label is allowed to overlap into the spacer
      row_height += Math.max(this.y_num_height/2, this.name_spacer); 
      //the label is allowed to overlap the space used by the other label
      row_height += Math.max(this.y_num_height/2, this.x_num_height + this.x_num_above); 
    } else {
      row_height += this.y_num_height/2; 
      //the label is allowed to overlap the space used by the other label
      row_height += Math.max(this.y_num_height/2, this.x_num_height + this.x_num_above); 
    }
    this.summed_height += row_height * (logo_rows - 1);
  }
  //the last row has the name and fine text below it but no padding
  this.summed_height += this.stack_height + (this.y_axis ? this.y_num_height/2 : 0);

  var fine_txt_total = (has_finetext ? this.fine_txt_height + this.fine_txt_above : 0);
  if (has_names) {
    this.summed_height += fine_txt_total + this.name_height;
    this.summed_height += Math.max((this.y_axis ? this.y_num_height/2 : 0), 
        this.x_num_height + this.x_num_above + this.name_spacer);
  } else {
    this.summed_height += Math.max((this.y_axis ? this.y_num_height/2 : 0), 
        this.x_num_height + this.x_num_above + fine_txt_total);
  }

  //calculate how much horizontal space we want to draw this
  //first add the padding at the left and right since that's always there
  this.summed_width += this.pad_left + this.pad_right;
  if (this.y_axis) {
    //add on the space for the y-axis label
    this.summed_width += this.y_label_height + this.y_label_spacer;
    //add on the space for the y-axis
    this.summed_width += this.y_num_width + this.y_tic_width;
  }
  //add on the space for the stacks
  this.summed_width += (this.stack_pad_left + this.stack_width) * logo_columns;
  //add on the padding after the stacks (an offset from the fine text)
  this.summed_width += this.stacks_pad_right;

};

//======================================================================
// end LogoMetrics object
//======================================================================

//found this trick at http://talideon.com/weblog/2005/02/detecting-broken-images-js.cfm
function image_ok(img) {
  "use strict";
  // During the onload event, IE correctly identifies any images that
  // weren't downloaded as not complete. Others should too. Gecko-based
  // browsers act like NS4 in that they report this incorrectly.
  if (!img.complete) {
    return false;
  }
  // However, they do have two very useful properties: naturalWidth and
  // naturalHeight. These give the true size of the image. If it failed
  // to load, either of these should be zero.
  if (typeof img.naturalWidth !== "undefined" && img.naturalWidth === 0) {
    return false;
  }
  // No other way of checking: assume it's ok.
  return true;
}
  
function supports_text(ctx) {
  "use strict";
  if (!ctx.fillText) {
    return false;
  }
  if (!ctx.measureText) {
    return false;
  }
  return true;
}

//draws the scale, returns the width
function draw_scale(ctx, metrics, alphabet_ic, raster) {
  "use strict";
  var tic_height, i;
  tic_height = metrics.stack_height / alphabet_ic;
  ctx.save();
  ctx.translate(metrics.y_label_height, metrics.y_num_height/2);
  //draw the axis label
  ctx.save();
  ctx.font = metrics.y_label_font;
  ctx.translate(0, metrics.stack_height/2);
  ctx.rotate(-(Math.PI / 2));
  ctx.textAlign = "center";
  ctx.fillText("bits", 0, 0);
  ctx.restore();

  ctx.translate(metrics.y_label_spacer + metrics.y_num_width, 0);

  //draw the axis tics
  ctx.save();
  ctx.translate(0, metrics.stack_height);
  for (i = 0; i <= alphabet_ic; i++) {
    //draw the number
    ctx.save();
    ctx.translate(-1, 0);
    raster.draw_scale_num(ctx, metrics.y_num_font, i);
    ctx.restore();
    //draw the tic
    ctx.fillRect(0, -1, metrics.y_tic_width, 2);
    //prepare for next tic
    ctx.translate(0, -tic_height);
  }
  ctx.restore();

  ctx.fillRect(metrics.y_tic_width - 2, 0, 2, metrics.stack_height)

  ctx.restore();
}

function draw_stack_num(ctx, metrics, row_index, raster) {
  "use strict";
  ctx.save();
  ctx.translate(0, Math.round(metrics.stack_height + metrics.x_num_above));
  if (metrics.x_axis == 1) {
    raster.draw_stack_num(ctx, metrics.x_num_font, metrics.stack_width, row_index);
  } else if (metrics.x_axis == 0) {
    // draw dots instead of the numbers (good for small logos)
    ctx.beginPath();
    var radius = Math.round(metrics.x_num_height / 2);
    ctx.arc(Math.round(metrics.stack_width / 2), radius, radius, 0, 2 * Math.PI, false);
    ctx.fill();
  }
  ctx.restore();
}

function draw_stack(ctx, metrics, symbols, raster) {
  "use strict";
  var preferred_pad, sym_min, i, sym, sym_height, pad;
  preferred_pad = 0;
  sym_min = 5;

  ctx.save();//1
  ctx.translate(0, metrics.stack_height);
  for (i = 0; i < symbols.length; i++) {
    sym = symbols[i];
    sym_height = metrics.stack_height * sym.get_scale();
    
    pad = preferred_pad;
    if (sym_height - pad < sym_min) {
      pad = Math.min(pad, Math.max(0, sym_height - sym_min));
    }
    sym_height -= pad;

    //translate to the correct position
    ctx.translate(0, -(pad/2 + sym_height));

    //draw
    raster.draw_stack_sym(ctx, sym.get_symbol(), 0, 0, metrics.stack_width, sym_height);
    //translate past the padding
    ctx.translate(0, -(pad/2));
  }
  ctx.restore();//1
}

function draw_dashed_line(ctx, pattern, start, x1, y1, x2, y2) {
  "use strict";
  var x, y, len, i, dx, dy, tlen, theta, mulx, muly, lx, ly;
  dx = x2 - x1;
  dy = y2 - y1;
  tlen = Math.pow(dx*dx + dy*dy, 0.5);
  theta = Math.atan2(dy,dx);
  mulx = Math.cos(theta);
  muly = Math.sin(theta);
  lx = [];
  ly = [];
  for (i = 0; i < pattern; ++i) {
    lx.push(pattern[i] * mulx);
    ly.push(pattern[i] * muly);
  }
  i = start;
  x = x1;
  y = y1;
  len = 0;
  ctx.beginPath();
  while (len + pattern[i] < tlen) {
    ctx.moveTo(x, y);
    x += lx[i];
    y += ly[i];
    ctx.lineTo(x, y);
    len += pattern[i];
    i = (i + 1) % pattern.length;
    x += lx[i];
    y += ly[i];
    len += pattern[i];
    i = (i + 1) % pattern.length;
  }
  if (len < tlen) {
    ctx.moveTo(x, y);
    x += mulx * (tlen - len);
    y += muly * (tlen - len);
    ctx.lineTo(x, y);
  }
  ctx.stroke();
}

function draw_trim_background(ctx, metrics, left_start, left_end, left_divider, right_start, right_end, right_divider) {
  "use strict";
  var left_size = left_end - left_start;
  var right_size = right_end - right_start;
  var line_x;

  ctx.save();//s8
  ctx.fillStyle = "rgb(240, 240, 240)";
  if (left_size > 0) {
    ctx.fillRect(left_start * metrics.stack_width, 0, left_size * metrics.stack_width, metrics.stack_height);
  }
  if (right_size > 0) {
    ctx.fillRect(right_start * metrics.stack_width, 0, right_size * metrics.stack_width, metrics.stack_height);
  }
  ctx.fillStyle = "rgb(51, 51, 51)";
  if (left_size > 0 && left_divider) {
    line_x = (left_end * metrics.stack_width) - 0.5;
    draw_dashed_line(ctx, [3], 0, line_x, 0, line_x, metrics.stack_height);
  }
  if (right_size > 0 && right_divider) {
    line_x = (right_start * metrics.stack_width) + 0.5;
    draw_dashed_line(ctx, [3], 0, line_x, 0, line_x, metrics.stack_height);
  }
  ctx.restore();//s8
}

function size_logo_on_canvas(logo, canvas, show_names, scale) {
  "use strict";
  var draw_name, draw_finetext, metrics;
  draw_name = (typeof show_names === "boolean" ? show_names : (logo.get_rows() > 1));
  draw_finetext = (logo.fine_text.length > 0);
  if (canvas.width !== 0 && canvas.height !== 0) {
    return;
  }
  metrics = new LogoMetrics(canvas.getContext('2d'), 
      logo.get_xlate_columns(), logo.get_rows(), draw_name, draw_finetext, logo.x_axis, logo.y_axis);
  if (typeof scale == "number") {
    //resize the canvas to fit the scaled logo
    canvas.width = metrics.summed_width * scale;
    canvas.height = metrics.summed_height * scale;
  } else {
    if (canvas.width === 0 && canvas.height === 0) {
      canvas.width = metrics.summed_width;
      canvas.height = metrics.summed_height;
    } else if (canvas.width === 0) {
      canvas.width = metrics.summed_width * (canvas.height / metrics.summed_height);
    } else if (canvas.height === 0) {
      canvas.height = metrics.summed_height * (canvas.width / metrics.summed_width);
    }
  }
}

function draw_logo_on_canvas(logo, canvas, show_names, scale) {
  "use strict";
  var i, draw_name, draw_finetext, ctx, metrics, raster, pspm_i, pspm, 
      offset, col_index, motif_position, ssc;
  ssc = false;
  draw_name = (typeof show_names === "boolean" ? show_names : (logo.get_rows() > 1));
  draw_finetext = (logo.fine_text.length > 0);
  ctx = canvas.getContext('2d');
  //assume that the user wants the canvas scaled equally so calculate what the best width for this image should be
  metrics = new LogoMetrics(ctx, logo.get_xlate_columns(), logo.get_rows(), draw_name, draw_finetext, logo.x_axis, logo.y_axis);
  if (typeof scale == "number") {
    //resize the canvas to fit the scaled logo
    canvas.width = metrics.summed_width * scale;
    canvas.height = metrics.summed_height * scale;
  } else {
    if (canvas.width === 0 && canvas.height === 0) {
      scale = 1;
      canvas.width = metrics.summed_width;
      canvas.height = metrics.summed_height;
    } else if (canvas.width === 0) {
      scale = canvas.height / metrics.summed_height;
      canvas.width = metrics.summed_width * scale;
    } else if (canvas.height === 0) {
      scale = canvas.width / metrics.summed_width;
      canvas.height = metrics.summed_height * scale;
    } else {
      scale = Math.min(canvas.width / metrics.summed_width, canvas.height / metrics.summed_height);
    }
  }
  // cache the raster based on the assumption that we will be drawing a lot
  // of logos the same size and alphabet
  if (typeof draw_logo_on_canvas.raster_cache === "undefined") {
    draw_logo_on_canvas.raster_cache = [];
  }
  for (i = 0; i < draw_logo_on_canvas.raster_cache.length; i++) {
    raster = draw_logo_on_canvas.raster_cache[i];
    if (raster.get_alphabet().equals(logo.alphabet) &&
        Math.abs(raster.get_scale() - scale) < 0.1) break;
    raster = null;
  }
  if (raster == null) {
    raster = new RasterizedAlphabet(logo.alphabet, scale, metrics.stack_font, metrics.stack_width);
    draw_logo_on_canvas.raster_cache.push(raster);
  }
  ctx = canvas.getContext('2d');
  ctx.save();//s1
  ctx.scale(scale, scale);
  ctx.save();//s2
  ctx.save();//s7
  //create margin
  ctx.translate(Math.round(metrics.pad_left), Math.round(metrics.pad_top));
  for (pspm_i = 0; pspm_i < logo.get_rows(); ++pspm_i) {
    pspm = logo.get_pspm(pspm_i);
    offset = logo.get_offset(pspm_i);
    //optionally draw name if this isn't the last row or is the only row 
    if (draw_name && (logo.get_rows() == 1 || pspm_i != (logo.get_rows()-1))) {
      ctx.save();//s4
      ctx.translate(Math.round(metrics.summed_width/2), Math.round(metrics.name_height));
      ctx.font = metrics.name_font;
      ctx.textAlign = "center";
      ctx.fillText(pspm.name, 0, 0);
      ctx.restore();//s4
      ctx.translate(0, Math.round(metrics.name_height + 
          Math.min(0, metrics.name_spacer - metrics.y_num_height/2)));
    }
    //draw scale
    if (logo.y_axis) draw_scale(ctx, metrics, logo.alphabet.get_ic(), raster);
    ctx.save();//s5
    //translate across past the scale
    if (logo.y_axis) {
      ctx.translate(Math.round(metrics.y_label_height + metrics.y_label_spacer + 
        metrics.y_num_width + metrics.y_tic_width), Math.round(metrics.y_num_height / 2));
    }
    //draw the trimming background
    if (pspm.get_left_trim() > 0 || pspm.get_right_trim() > 0) {
      var left_start = offset * logo.get_xlate_nsyms();
      var left_end = (offset + pspm.get_left_trim()) * logo.get_xlate_nsyms();
      var left_divider = true;
      if (left_end < logo.get_xlate_start() || left_start > logo.get_xlate_end()) {
        // no overlap
        left_start = 0;
        left_end = 0;
        left_divider = false;
      } else {
        if (left_start < logo.get_xlate_start()) {
          left_start = logo.get_xlate_start();
        }
        if (left_end > logo.get_xlate_end()) {
          left_end = logo.get_xlate_end();
          left_divider = false;
        }
        left_start -= logo.get_xlate_start();
        left_end -= logo.get_xlate_start();
        if (left_end < left_start) {
          left_start = 0;
          left_end = 0;
          left_divider = false;
        }
      }
      var right_end = (offset + pspm.get_motif_length()) * logo.get_xlate_nsyms();
      //var right_start = right_end - (pspm.get_left_trim() * logo.get_xlate_nsyms());
      var right_start = right_end - (pspm.get_right_trim() * logo.get_xlate_nsyms());
      var right_divider = true;
      if (right_end < logo.get_xlate_start() || right_start > logo.get_xlate_end()) {
        // no overlap
        right_start = 0;
        right_end = 0;
        right_divider = false;
      } else {
        if (right_start < logo.get_xlate_start()) {
          right_start = logo.get_xlate_start();
          right_divider = false;
        }
        if (right_end > logo.get_xlate_end()) {
          right_end = logo.get_xlate_end();
        }
        right_start -= logo.get_xlate_start();
        right_end -= logo.get_xlate_start();
        if (right_end < right_start) {
          right_start = 0;
          right_end = 0;
          right_divider = false;
        }
      }
      draw_trim_background(ctx, metrics, left_start, left_end, left_divider, right_start, right_end, right_divider);
    }
    //draw letters
    var xlate_col;
    for (xlate_col = logo.get_xlate_start(); xlate_col < logo.get_xlate_end(); xlate_col++) {
      ctx.translate(metrics.stack_pad_left,0);
      col_index = Math.floor(xlate_col / logo.get_xlate_nsyms());
      if (xlate_col % logo.get_xlate_nsyms() == 0) {
        if (col_index >= offset && col_index < (offset + pspm.get_motif_length())) {
          motif_position = col_index - offset;
          draw_stack_num(ctx, metrics, motif_position, raster);
          draw_stack(ctx, metrics, pspm.get_stack(motif_position, logo.alphabet, ssc), raster);
        }
      } else {
        if (col_index >= offset && col_index < (offset + pspm.get_motif_length())) {
          ctx.save();// s5.1
          ctx.translate(0, Math.round(metrics.stack_height));
          // TODO draw a dot or dash or something to indicate continuity of the motif
          ctx.restore(); //s5.1
        }
      }
      ctx.translate(Math.round(metrics.stack_width), 0);
    }
    ctx.restore();//s5
    ////optionally draw name if this is the last row but isn't the only row 
    if (draw_name && (logo.get_rows() != 1 && pspm_i == (logo.get_rows()-1))) {
      //translate vertically past the stack and axis's        
      ctx.translate(0, metrics.y_num_height/2 + metrics.stack_height + 
          Math.max(metrics.y_num_height/2, metrics.x_num_above + metrics.x_num_width + metrics.name_spacer));

      ctx.save();//s6
      ctx.translate(metrics.summed_width/2, metrics.name_height);
      ctx.font = metrics.name_font;
      ctx.textAlign = "center";
      ctx.fillText(pspm.name, 0, 0);
      ctx.restore();//s6
      ctx.translate(0, metrics.name_height);
    } else {
      //translate vertically past the stack and axis's        
      ctx.translate(0, metrics.y_num_height/2 + metrics.stack_height + 
          Math.max(metrics.y_num_height/2, metrics.x_num_above + metrics.x_num_width));
    }
    //if not the last row then add middle padding
    if (pspm_i != (logo.get_rows() -1)) {
      ctx.translate(0, metrics.pad_middle);
    }
  }
  ctx.restore();//s7
  if (logo.fine_text.length > 0) {
    ctx.translate(metrics.summed_width - metrics.pad_right, metrics.summed_height - metrics.pad_bottom);
    ctx.font = metrics.fine_txt_font;
    ctx.textAlign = "right";
    ctx.fillText(logo.fine_text, 0,0);
  }
  ctx.restore();//s2
  ctx.restore();//s1
}

function create_canvas(c_width, c_height, c_id, c_title, c_display) {
  "use strict";
  var canvas = document.createElement("canvas");
  //check for canvas support before attempting anything
  if (!canvas.getContext) {
    return null;
  }
  var ctx = canvas.getContext('2d');
  //check for html5 text drawing support
  if (!supports_text(ctx)) {
    return null;
  }
  //size the canvas
  canvas.width = c_width;
  canvas.height = c_height;
  canvas.id = c_id;
  canvas.title = c_title;
  canvas.style.display = c_display;
  return canvas;
}

function logo_1(alphabet, fine_text, pspm) {
  "use strict";
  var logo = new Logo(alphabet, fine_text);
  logo.add_pspm(pspm);
  return logo;
}

function logo_2(alphabet, fine_text, target, query, query_offset) {
  "use strict";
  var logo = new Logo(alphabet, fine_text);
  if (query_offset < 0) {
    logo.add_pspm(target, -query_offset);
    logo.add_pspm(query);
  } else {
    logo.add_pspm(target);
    logo.add_pspm(query, query_offset);
  }      
  return logo;
}

/*
 * Specifies an alternate source for an image.
 * If the image with the image_id specified has
 * not loaded then a generated logo will be used 
 * to replace it.
 *
 * Note that the image must either have dimensions
 * or a scale must be set.
 */
function alternate_logo(logo, image_id, scale) {
  "use strict";
  var image = document.getElementById(image_id);
  if (!image) {
    alert("Can't find specified image id (" +  image_id + ")");
    return;
  }
  //if the image has loaded then there is no reason to use the canvas
  if (image_ok(image)) {
    return;
  }
  //the image has failed to load so replace it with a canvas if we can.
  var canvas = create_canvas(image.width, image.height, image_id, image.title, image.style.display);
  if (canvas === null) {
    return;
  }
  //draw the logo on the canvas
  draw_logo_on_canvas(logo, canvas, null, scale);
  //replace the image with the canvas
  image.parentNode.replaceChild(canvas, image);
}

/*
 * Specifies that the element with the specified id
 * should be replaced with a generated logo.
 */
function replace_logo(logo, replace_id, scale, title_txt, display_style) {
  "use strict";
  var element = document.getElementById(replace_id);
  if (!replace_id) {
    alert("Can't find specified id (" + replace_id + ")");
    return;
  }
  //found the element!
  var canvas = create_canvas(50, 120, replace_id, title_txt, display_style);
  if (canvas === null) {
    return;
  }
  //draw the logo on the canvas
  draw_logo_on_canvas(logo, canvas, null, scale);
  //replace the element with the canvas
  element.parentNode.replaceChild(canvas, element);
}

/*
 * Fast string trimming implementation found at
 * http://blog.stevenlevithan.com/archives/faster-trim-javascript
 *
 * Note that regex is good at removing leading space but
 * bad at removing trailing space as it has to first go through
 * the whole string.
 */
function trim (str) {
  "use strict";
  var ws, i;
  str = str.replace(/^\s\s*/, '');
  ws = /\s/; i = str.length;
  while (ws.test(str.charAt(--i)));
  return str.slice(0, i + 1);
}
</script>
    <script>
var tomtom_alphabet = new Alphabet(data.alphabet, data.background);

var DelayLogoTask = function(logo, canvas) {
  this.logo = logo;
  this.canvas = canvas;
};

DelayLogoTask.prototype.run = function () {
  draw_logo_on_canvas(this.logo, this.canvas);
};

function make_logo(alphabet, pspm, rc, offset, className) {
  if (rc) pspm = pspm.copy().reverse_complement(alphabet);
  var logo = new Logo(alphabet, "");
  logo.add_pspm(pspm, offset);
  var canvas = document.createElement('canvas');
  canvas.height = 50;
  canvas.width = 0;
  canvas.className = className;
  size_logo_on_canvas(logo, canvas);
  add_draw_task(canvas, new DelayLogoTask(logo, canvas));
  return canvas;
}

function make_name(motif, should_link) {
  var name, link;
  name = motif.id + (typeof motif.alt === "string" ? " (" + motif.alt + ")" : "");
  if (should_link && typeof motif.url === "string") {
    link = document.createElement("a");
    link.href = motif.url;
    link.appendChild(document.createTextNode(name));
    return link;
  } else {
    return document.createTextNode(name);
  }
}

function make_logo_form() {
  $("logo_form").action = site_url + "/utilities/generate_logo";
  $("download_submit").addEventListener("click", function() {
    toggle_class(document.getElementById("download"), "hidden", true);
  }, false);
  $("download_cancel").addEventListener("click", function() {
    toggle_class(document.getElementById("download"), "hidden", true);
  }, false);
}

function make_alignment(query, target, rc, offset) {
  var logo, query_pspm, target_pspm;
  logo = new Logo(tomtom_alphabet, "");
  query_pspm = new Pspm(query.pwm, query.id, 0, 0, query.nsites);
  target_pspm = new Pspm(target.pwm, target.id, 0, 0, target.nsites);
  if (rc) target_pspm.reverse_complement(tomtom_alphabet);
  logo.add_pspm(target_pspm, (offset < 0 ? -offset : 0));
  logo.add_pspm(query_pspm, (offset < 0 ? 0 : offset));
  var canvas = document.createElement('canvas');
  canvas.height = 300;
  canvas.width = 0;
  canvas.title = "Click to show download options";
  size_logo_on_canvas(logo, canvas);
  add_draw_task(canvas, new DelayLogoTask(logo, canvas));
  return canvas;
}

function make_preview() {
  var i, j, qidx, tidx, query, target, match, matches, pview_table, pview_tbody, pview_row;
  var row, row_mlist, mlink;
  // scan the matches make a lookup from query index to matches index
  var lookup = {};
  for (i = 0; i < data.all_matches.length; i++) {
    lookup[data.all_matches[i].idx] = i;
  }

  pview_table = $("preview");
  pview_row = pview_table.querySelector(".pview_row");
  pview_tbody = pview_row.parentNode;
  pview_tbody.removeChild(pview_row);
  for (qidx = 0; qidx < data.queries.length; qidx++) {
    query = data.queries[qidx];
    matches = (lookup[qidx] != null ? data.all_matches[lookup[qidx]].matches : []);
    row = pview_row.cloneNode(true);
    row.querySelector(".pview_db").appendChild(document.createTextNode(data.query_dbs[query.db].name));
    row.querySelector(".pview_name").appendChild(document.createTextNode(query.id));
    if (typeof query.alt === "string") row.querySelector(".pview_alt").appendChild(document.createTextNode(query.alt));
    row.querySelector(".pview_logo").appendChild(make_logo(tomtom_alphabet, new Pspm(query.pwm)));
    row.querySelector(".pview_matches").appendChild(document.createTextNode(matches.length));
    row_mlist = row.querySelector(".pview_list");
    for (j = 0; j < matches.length; j++) {
      if (j > 0) row_mlist.appendChild(document.createTextNode(",\u2003 "));// EM Space
      match = matches[j];
      tidx = match.idx;
      target = data.targets[tidx];
      mlink = document.createElement("a");
      mlink.className = (qidx % 2 == 0 ? "ml1" : "ml2");
      mlink.appendChild(document.createTextNode(target.id));
      if (typeof target.alt === "string") mlink.appendChild(document.createTextNode("\u00A0(" + target.alt + ")"));
      mlink.href = "#match_" + qidx + "_" + tidx;
      row_mlist.appendChild(mlink);
    }
    pview_tbody.appendChild(row);
  }
}

function make_target_dbs() {
  var i, tdb_table, tdb_row, tdb_tbody, db;
  var row, match_count;
  tdb_table = $("tdbs");
  tdb_row = tdb_table.querySelector(".db_row");
  tdb_tbody = tdb_row.parentNode;
  tdb_tbody.removeChild(tdb_row);
  match_count = [];
  for (i = 0; i < data.target_dbs.length; i++) match_count[i] = 0;
  for (i = 0; i < data.targets.length; i++) {
    match_count[data.targets[i].db]++;
  }
  for (i = 0; i < data.target_dbs.length; i++) {
    db = data.target_dbs[i];
    row = tdb_row.cloneNode(true);
    row.querySelector(".db_name").appendChild(document.createTextNode(db.name));
    row.querySelector(".db_used").appendChild(document.createTextNode(db.loaded - db.excluded));
    row.querySelector(".db_matched").appendChild(document.createTextNode(match_count[i]));
    tdb_tbody.appendChild(row);
  }
  $("link_after_target_db").href = (data.all_matches.length > 0 ? "#query_" + data.all_matches[0].idx : "#settings");
}

function custom_logo(elem, qidx, tidx, rc, offset) {
  "use strict";
  function helper(qidx, tidx, rc, offset) {
    "use strict";
    return function() {
      if ($("dl_flip").value == "1") {
        $("dl_rc1").value = (rc ? "0" : "1");
        $("dl_rc2").value = "1";
        $("dl_shift").value = -(data.targets[tidx].len - (data.queries[qidx].len + offset));
      } else {
        $("dl_rc1").value = (rc ? "1" : "0");
        $("dl_rc2").value = "0";
        $("dl_shift").value = -offset;
      }
    };
  }
  var download_prompt, qidx, tidx, rc, offset, query, target, qmotif, tmotif;
  var flip_handler;
  // get the download prompt
  download_prompt = document.getElementById("download");
  // hide previous showing of the download prompt
  toggle_class(download_prompt, "hidden", true);
  if (typeof custom_logo.flip_handler !== "undefined") {
    $("dl_flip").removeEventListener("change", custom_logo.flip_handler, false);
  }
  // reset defaults on prompt
  $("dl_flip").value = "0";
  $("dl_width").value = "";
  $("dl_height").value = "";
  // configure download prompt to the selected logo
  query = data.queries[qidx];
  target = data.targets[tidx];
  tmotif = new Pspm(target.pwm, "1", 0, 0, target.nsites, target.evalue);
  qmotif = new Pspm(query.pwm, "2", 0, 0, query.nsites, query.evalue);
  $("dl_motifs").value = tmotif.as_meme({"with_header": true, "alphabet": tomtom_alphabet}) + qmotif.as_meme();
  $("dl_label1").value = target.id;
  $("dl_label2").value = query.id;
  flip_handler = helper(qidx, tidx, rc, offset);
  $("dl_flip").addEventListener("change", flip_handler, false);
  custom_logo.flip_handler = flip_handler;
  flip_handler();
  // position and display the download prompt
  position_popup(elem, download_prompt, 1);
  toggle_class(download_prompt, "hidden", false);
  // focus the download button
  $("download_submit").focus();
}

function make_custom_logo_handler(elem, qidx, tidx, rc, offset) {
  return function(evt) {
    custom_logo(elem, qidx, tidx, rc, offset);
    evt.preventDefault();
  };
}

function make_matches() {
  var i, j, matches_box, match_box, match_entry, box, links, entries, entry;
  var qidx, query, tidx, target, matches, overlap, rc, logo_container;
  var prev_query_link, next_query_link;
  matches_box = $("matches");
  match_box = matches_box.querySelector(".match_box");
  matches_box.removeChild(match_box);
  for (i = 0; i < data.all_matches.length; i++) {
    matches = data.all_matches[i].matches;
    qidx = data.all_matches[i].idx;
    query = data.queries[qidx];
    box = match_box.cloneNode(true);
    box.id = "query_" + qidx;
    box.querySelector(".query_name").appendChild(make_name(query, false));
    links = box.querySelector(".links");
    prev_query_link = (i == 0 ? "#target_dbs" : "#query_" + data.all_matches[i-1].idx);
    next_query_link = ((i + 1) >= data.all_matches.length ? "#settings" : "#query_" + data.all_matches[i+1].idx);
    links.querySelector(".prev").href = prev_query_link;
    links.querySelector(".next").href = next_query_link;
    match_entry = box.querySelector(".match_entry");
    entries = match_entry.parentNode;
    entries.removeChild(match_entry);
    for (j = 0; j < matches.length; j++) {
      tidx = matches[j].idx;
      target = data.targets[tidx];
      entry = match_entry.cloneNode(true);
      entry.id = "match_" + qidx + "_" + tidx;
      entry.querySelector(".match_name").appendChild(make_name(target, true));
      entry.querySelector(".match_db").appendChild(document.createTextNode(data.target_dbs[target.db].name));
      entry.querySelector(".match_pvalue").appendChild(document.createTextNode(matches[j].pv));
      entry.querySelector(".match_evalue").appendChild(document.createTextNode(matches[j].ev));
      entry.querySelector(".match_qvalue").appendChild(document.createTextNode(matches[j].qv));
      if (matches[j].off < 0) {
        overlap = Math.min(query.pwm.length + matches[j].off, target.pwm.length);
      } else if (matches[j].off == 0) {
        overlap = Math.min(query.pwm.length, target.pwm.length);
      } else {
        overlap = Math.min(query.pwm.length, target.pwm.length - matches[j].off);
      }
      entry.querySelector(".match_overlap").appendChild(document.createTextNode(overlap));
      entry.querySelector(".match_offset").appendChild(document.createTextNode(matches[j].off));
      rc = (typeof matches[j].rc === "boolean" && matches[j].rc);
      entry.querySelector(".match_orientation").appendChild(document.createTextNode(rc ? "Reverse Complement" : "Normal"));
      logo_container = entry.querySelector(".logo_container");
      logo_container.appendChild(make_alignment(query, target, rc, matches[j].off));
      entries.appendChild(entry);
      var custom_logo_handler = make_custom_logo_handler(logo_container.querySelector("canvas"), qidx, tidx, rc, matches[j].off);
      entry.querySelector(".download_btn").addEventListener("click", custom_logo_handler, false);
      entry.querySelector(".download_text").addEventListener("click", custom_logo_handler, false);
      entry.querySelector("canvas").addEventListener("click", custom_logo_handler, false);
      if (i != 0) entry.querySelector(".prev_query").href = prev_query_link;
      if ((i + 1) < data.all_matches.length) entry.querySelector(".next_query").href = next_query_link;
      if (j != 0) {
        entry.querySelector(".prev_target").href = "#match_" + qidx + "_" + matches[j-1].idx;
      } else if (i != 0) {
        var prev_query =  data.all_matches[i-1];
        var prev_qidx = prev_query.idx;
        var prev_matches = prev_query.matches;
        var prev_tidx = prev_matches[prev_matches.length - 1].idx;
        entry.querySelector(".prev_target").href = "#match_" + prev_qidx + "_" + prev_tidx;
      }
      if ((j + 1) < matches.length) {
        entry.querySelector(".next_target").href = "#match_" + qidx + "_" + matches[j+1].idx;
      } else if ((i + 1) < data.all_matches.length) {
        var next_query = data.all_matches[i+1];
        var next_qidx = next_query.idx;
        var next_matches = next_query.matches;
        var next_tidx = next_matches[0].idx;
        entry.querySelector(".next_target").href = "#match_" + next_qidx + "_" + next_tidx;
      }
    }

    matches_box.appendChild(box);
  }

}

function make_program() {
  $("link_before_program").href = (data.all_matches.length > 0 ? "#query_" + data.all_matches[data.all_matches.length - 1].idx : "#target_dbs");
  $("version").appendChild(document.createTextNode(data.version));
  $("release").appendChild(document.createTextNode(data.release));
  $("cmd").value = data.cmd.join(" ");
  $("runtime").appendChild(document.createTextNode(data.runtime.seconds));
}
</script>
    <style>
/* The following is the content of meme.css */
body { background-color:white; font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif;}

div.help {
  display: inline-block;
  margin: 0px;
  padding: 0px;
  width: 12px;
  height: 13px;
  cursor: pointer;
  background-image: url(data:image/gif;base64,R0lGODlhDAANAIABANR0AP///yH5BAEAAAEALAAAAAAMAA0AAAIdhI8Xy22MIFgv1DttrrJ7mlGNNo4c+aFg6SQuUAAAOw==);
}

div.help:hover {
  background-image: url(data:image/gif;base64,R0lGODlhDAANAKEAANR0AP///9R0ANR0ACH+EUNyZWF0ZWQgd2l0aCBHSU1QACH5BAEAAAIALAAAAAAMAA0AAAIdDGynCe3PgoxONntvwqz2/z2K2ImjR0KhmSIZUgAAOw==);
}

p.spaced { line-height: 1.8em;}

span.citation { font-family: "Book Antiqua", "Palatino Linotype", serif; color: #004a4d;}

p.pad { padding-left: 30px; padding-top: 5px; padding-bottom: 10px;}

td.jump { font-size: 13px; color: #ffffff; background-color: #00666a;
  font-family: Georgia, "Times New Roman", Times, serif;}

a.jump { margin: 15px 0 0; font-style: normal; font-variant: small-caps;
  font-weight: bolder; font-family: Georgia, "Times New Roman", Times, serif;}

h2.mainh {font-size: 1.5em; font-style: normal; margin: 15px 0 0;
  font-variant: small-caps; font-family: Georgia, "Times New Roman", Times, serif;}

h2.line {border-bottom: 1px solid #CCCCCC; font-size: 1.5em; font-style: normal;
  margin: 15px 0 0; padding-bottom: 3px; font-variant: small-caps;
  font-family: Georgia, "Times New Roman", Times, serif;}

h4 {border-bottom: 1px solid #CCCCCC; font-size: 1.2em; font-style: normal;
  margin: 10px 0 0; padding-bottom: 3px; font-family: Georgia, "Times New Roman", Times, serif;}

h5 {margin: 0px}

a.help { font-size: 9px; font-style: normal; text-transform: uppercase;
  font-family: Georgia, "Times New Roman", Times, serif;}

div.pad { padding-left: 30px; padding-top: 5px; padding-bottom: 10px;}

div.pad1 { margin: 10px 5px;}

div.pad2 { margin: 25px 5px 5px;}
h2.pad2 { padding: 25px 5px 5px;}

div.pad3 { padding: 5px 0px 10px 30px;}

div.box { border: 2px solid #CCCCCC; padding:10px; overflow: hidden;}

div.bar { border-left: 7px solid #00666a; padding:5px; margin-top:25px; }

div.subsection {margin:25px 0px;}

img {border:0px none;}

th.majorth {text-align:left;}
th.minorth {font-weight:normal; text-align:left; width:8em; padding: 3px 0px;}
th.actionth {font-weight:normal; text-align:left;}

.explain h5 {font-size:1em; margin-left: 1em;}

div.doc {margin-left: 2em; margin-bottom: 3em;}

th.trainingset {
  border-bottom: thin dashed black; 
  font-weight:normal; 
  padding:0px 10px;
}
div.pop_content {
  position:absolute;
  z-index:50;
  width:300px;
  padding: 5px;
  background: #E4ECEC;
  font-size: 12px;
  font-family: Arial;
  border-style: double;
  border-width: 3px;
  border-color: #AA2244;
  display:none;
}

div.pop_content > *:first-child {
  margin-top: 0px;
}

div.pop_content h1, div.pop_content h2, div.pop_content h3, div.pop_content h4, 
div.pop_content h5, div.pop_content h6, div.pop_content p {
  margin: 0px;
}

div.pop_content p + h1, div.pop_content p + h2, div.pop_content p + h3, 
div.pop_content p + h4, div.pop_content p + h5, div.pop_content p + h6 {
  margin-top: 5px;
}

div.pop_content p + p {
  margin-top: 5px;
}

div.pop_content > *:last-child {
  margin-bottom: 0px;
}

div.pop_content div.pop_close {
  /* old definition */
  float:right;
  bottom: 0;
}

div.pop_content span.pop_close, div.pop_content span.pop_back {
  display: inline-block;
  border: 2px outset #661429;
  background-color: #CCC;
  padding-left: 1px;
  padding-right: 1px;
  padding-top: 0px;
  padding-bottom: 0px;
  cursor: pointer;
  color: #AA2244; /*#661429;*/
  font-weight: bold;
}

div.pop_content span.pop_close:active, div.pop_content span.pop_back:active {
  border-style: inset;
}

div.pop_content span.pop_close {
  float:right;
  /*border: 2px outset #AA002B;*/
  /*color: #AA2244;*/
}

div.pop_content:not(.nested) .nested_only {
  display: none;
}

div.pop_back_sec {
  margin-bottom: 5px;
}

div.pop_close_sec {
  margin-top: 5px;
}

table.hide_advanced tr.advanced {
  display: none;
}
span.show_more {
  display: none;
}
table.hide_advanced span.show_more {
  display: inline;
}
table.hide_advanced span.show_less {
  display: none;
}


/*****************************************************************************
 * Program logo styling
 ****************************************************************************/
div.prog_logo {
  border-bottom: 0.25em solid #0f5f60;
  height: 4.5em;
  width: 24em;
  display:inline-block;
}
div.prog_logo img {
  float:left;
  width: 4em;
  border-style: none;
  margin-right: 0.2em;
}
div.prog_logo h1, div.prog_logo h1:hover, div.prog_logo h1:active, div.prog_logo h1:visited {
  margin:0;
  padding:0;
  font-family: Arial, Helvetica,  sans-serif;
  font-size: 3.2em;
  line-height: 1em;
  vertical-align: top;
  display: block;
  color: #026666;
  letter-spacing: -0.06em;
  text-shadow: 0.04em 0.06em 0.05em #666;
}
div.prog_logo h2, div.prog_logo h2:hover, div.prog_logo h2:active, div.prog_logo h2:visited {
  display: block;
  margin:0;
  padding:0;
  font-family: Helvetica, sans-serif;
  font-size: 0.9em;
  line-height: 1em;
  letter-spacing: -0.06em;
  color: black;
}

div.big.prog_logo {
  font-size: 18px;
}

</style>
    <style>
div.header {
  position: relative;
  overflow: hidden;
  margin-top: 15px;
  margin-bottom: 5px;
  margin-right: 3px;
  margin-left: 3px;
}
div.header > h2 {
  font-size: 1.5em;
  font-style: normal;
  margin: 0;
  font-variant: small-caps; 
  font-family: Georgia, "Times New Roman", Times, serif;
}
div.header > span {
  position: absolute;
  right: 0;
  bottom: 0;
}

table.th_ul th {
  white-space: nowrap;
  font-size: 1.2em;
  font-style: normal;
  font-family: Georgia, "Times New Roman", Times, serif;
}

table.th_ul th > span {
  display: block;
  border-bottom: 1px solid #CCCCCC;
  margin-right: 3px;
  padding-bottom: 1px; 
}

table.targets td {
  padding: 0 10px;
}
table.preview td {
  padding: 0 10px;
}
table.preview tbody td {
  padding-bottom: 10px;
}
.ac {
  text-align: center;
}
.downloadTd {
  padding-left:20px;
}
div.logo_container {
}
table.match_summary tbody tr:first-child td, table.match_summary tbody tr:first-child th {
  padding-top: 20px;
}

/* motif list link, first style */
a.ml1 {
}
a.ml2 {
}
div.ml {
  line-height: 1.8em;
  height: 3.6em;
  overflow-y: auto;
}
td.ml div {

}

table.match_summary {
  width: 100%;
}

table.match_summary th {
  min-width: 10em;
}

table.match_summary div.help, table.dl_opts div.help {
  opacity: 0.0;
    -moz-transition: opacity 0.5s;
    -webkit-transition: opacity 0.5s;
    -o-transition: opacity 0.5s;
    transition: opacity 0.5s;
}

table.match_summary tr:hover div.help, table.dl_opts tr:hover div.help {
  opacity: 1.0;
}

#download {
  position:absolute;
  display: inline-block;
  z-index:9;
  padding: 5px;
  background-color: #FFF;
  border-style: double;
  border-width: 5px;
  border-color: #00666a;
}

#download.hidden {
  visibility: hidden;
}

div.custom_logo {
  text-align: center;
  margin-top: 20px;
}

div.logo_container {
  position: relative;
}

div.logo_container canvas {
  cursor: pointer;
}

a.download_text {
  display: block;
  margin-top: 5px;
  margin-bottom: 20px;
  color: #00c;
  text-align: center;
}
a.download_text:hover { 
  color: #00c;
}
a.download_text:active {
  color: #c00;
}

a.prev_query, a.prev_target, a.next_target, a.next_query, a.download_btn {
  font-family: arial;
  font-size: xx-large;
  text-decoration: none;
  color: #000;
}
a.prev_query:hover, a.prev_target:hover, a.next_target:hover, a.next_query:hover, a.download_btn:hover {
  background: #000;
  color: #FFF;
}

a.prev_query {
  position: absolute;
  display: inline-block;
  right:0;
  top:0;
}
a.prev_target {
  position: absolute;
  display: inline-block;
  right:0;
  top: 30%;
  transform: translateY(-50%);
}
a.download_btn {
  position: absolute;
  display: inline-block;
  right:0;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
}
a.next_target {
  position: absolute;
  display: inline-block;
  right:0;
  top: 70%;
  transform: translateY(-50%);
}
a.next_query {
  position: absolute;
  display: inline-block;
  right:0;
  bottom:0;
}

a.prev_target:not([href]), a.next_target:not([href]), a.prev_query:not([href]), a.next_query:not([href]) {
  color: #BBB;
  cursor: pointer;
}
a.prev_target:hover:not([href]), a.next_target:hover:not([href]), a.prev_query:hover:not([href]), a.next_query:hover:not([href]) {
  color: #FFF;
  background: #BBB;
}

table.inputs, table.alpha_bg_table {
  margin-top: 20px;
  border-collapse:collapse;
}
table.inputs * td, table.inputs * th, table.alpha_bg_table * td, table.alpha_bg_table * th {
  padding-left: 15px;
  padding-right: 15px;
  padding-top: 1px;
  padding-bottom: 1px;
}

span.strand_none, span.strand_given, span.strand_both, span.dist_allr,
    span.dist_ed, span.dist_kullback, span.dist_pearson, span.dist_sandelin,
    span.dist_blic1, span.dist_blic5, span.dist_llr1, span.dist_llr5,
    span.ttype_evalue, span.ttype_qvalue {
  display: none;
}

td.none span.strand_none, td.given span.strand_given, td.both span.strand_both,
    td.allr span.dist_allr, td.ed span.dist_ed, td.kullback span.dist_kullback, 
    td.pearson span.dist_pearson, td.sandelin span.dist_sandelin,
    td.blic1 span.dist_blic1, td.blic5 span.dist_blic5, td.llr1 span.dist_llr1,
    td.llr5 span.dist_llr5, td.evalue span.ttype_evalue, td.qvalue span.ttype_qvalue {
  display: inline;
}
</style>
  </head>
  <body data-scrollpad="true">
    <div id="grey_out_page" class="grey_background" style="display:none;"></div>
    <!-- {{{ help topics -->
    <div class="pop_content" id="pop_results_tsv">
      <script>print_doc("pop_results_tsv", "tomtom-results-tsv");</script>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>

    <div class="pop_content" id="pop_query_db">
      <script>print_doc_para("pop_query_db", "motif-db", "the query motif(s). Tomtom removes the '.meme' file name extension, if present.");</script>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>

    <div class="pop_content" id="pop_query_name">
      <script>print_doc_para("pop_query_name", "motif-id", "query");</script>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_query_alt">
      <script>print_doc_para("pop_query_alt", "motif-alt-id", "query");</script>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_query_web">
      <p>A link to more information about the query motif.</p>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>

    <div class="pop_content" id="pop_motif_consensus">
      <script>print_doc("pop_motif_consensus", "motif-consensus");</script>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>

    <div class="pop_content" id="pop_query_preview">
      <p>The motif preview. On supporting browsers this will display as a motif
      logo, otherwise the <a href="javascript:help_refine('pop_motif_consensus')">consensus</a> sequence will be displayed.</p>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>

    <div class="pop_content" id="pop_query_matches">
      <p>The number motifs in the target database with a significant match to the query motif.</p>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>

    <div class="pop_content" id="pop_query_list">
      <p>Links to the (up to) twenty target motifs with the most significant matches to the query motif.</p>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>

    <div class="pop_content" id="pop_db_name">
      <script>print_doc_para("pop_db_name", "motif-db", "target motifs. Tomtom removes the '.meme' file name extension, if present.");</script>
    <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_db_used">
      <p>The number of motifs read from the motif database minus the number that
      had to be discarded due to conflicting IDs.</p>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_db_matched">
      <p>The number of motifs in this database that have a significant match to at least one of the query motifs.</p>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_match_summary">
      <p>The summary gives information about the target motif. Mouse over each
      row to show further help buttons for each specific title.</p>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_match_name">
      <p>The ID of the target motif with the optional alternate ID shown in parentheses.</p>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_match_db">
      <script>print_doc_para("pop_match_db", "motif-db", "the matched motif. Tomtom removes the '.meme' file name extension, if present.");</script>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_match_pvalue">
      <script>print_doc_para("pop_match_pvalue", "tomtom-p-value");</script>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_match_evalue">
      <script>print_doc_para("pop_match_evalue", "tomtom-E-value");</script>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_match_qvalue">
      <script>print_doc_para("pop_match_qvalue", "tomtom-q-value");</script>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_match_overlap">
      <script>print_doc_para("pop_match_overlap", "tomtom-overlap");</script>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_match_offset">
      <script>print_doc_para("pop_match_offset", "tomtom-offset");</script>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_match_orientation">
      <script>print_doc_para("pop_match_orientation", "tomtom-orientation", "<br>A value of 'Normal' means that the target motif is as it appears in the database. A value of 'Reverse Complement' means that the reverse complement of the target motif is shown.");</script>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_match_alignment">
      <p>The image shows the optimal alignment of the two motifs. The sequence logo
      of the target motif is shown aligned above the logo for the query motif.</p>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_match_download">
      <p>By clicking the link "Create custom LOGO &#8615;" a form to make custom logos 
      will be displayed. The download button can then be clicked to generate a motif
      matching the selected specifications.</p>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_dl_type">
      <p>Two image formats, png and eps, are available. The pixel based portable
      network graphic (png) format is commonly used on the Internet and the
      Encapsulated PostScript (eps) format is more suitable for publications
      that might require scaling.</p>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_dl_err">
      <p>Toggle error bars indicating the confidence of a motif based on the
      number of sites used in its creation.</p>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_dl_ssc">
      <p>Toggle adding pseudocounts for <b>S</b>mall <b>S</b>ample 
      <b>C</b>orrection.</p>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_dl_flip">
      <p>Toggle a full reverse complement of the alignment.</p>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    
    <div class="pop_content" id="pop_dl_width">
      <p>Specify the width of the generated logo.</p>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>

    <div class="pop_content" id="pop_dl_height">
      <p>Specify the height of the generated logo.</p>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>

    <div class="pop_content" id="pop_alph_name">
      <script>print_doc_para('pop_alph_name', 'alph-name', 'The ');</script>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>
    <div class="pop_content" id="pop_alph_bg">
      <script>print_doc_para('pop_alph_bg', 'alph-bg', 'The ');</script>
      <div class="pop_close">[<a href="javascript:help_popup()">close</a> ]</div>
    </div>

    <!-- }}} -->
    <div id="download" class="hidden">
      <form id="logo_form" method="post" action="">
        <input type="hidden" name="program" value="Tomtom"/>
        <input type="hidden" name="motifs" id="dl_motifs" value=""/>
        <input type="hidden" name="id1" value="1"/>
        <input type="hidden" name="rc1" id="dl_rc1" value="0"/>
        <input type="hidden" name="label1" id="dl_label1" value=""/>
        <input type="hidden" name="id2" value="2"/>
        <input type="hidden" name="rc2" id="dl_rc2" value="0"/>
        <input type="hidden" name="label2" id="dl_label2" value=""/>
        <input type="hidden" name="shift" id="dl_shift" value="0"/>
        <table class="dl_opts">
          <tr>
            <th>Image Type <div class="help" data-topic="pop_dl_type"></div></th>
            <td>
              <select name="png">
                <option value="1" selected>PNG</option>
                <option value="0">EPS</option>
              </select>
            </td>
          </tr>
          <tr>
            <th>Error bars <div class="help" data-topic="pop_dl_err"></div></th>
            <td>
              <select name="errbars">
                <option value="1" selected>yes</option>
                <option value="0">no</option>
              </select>
            </td>
          </tr>
          <tr>
            <th>SSC <div class="help" data-topic="pop_dl_ssc"></div></th>
            <td>
              <select name="ssc">
                <option value="1">yes</option>
                <option value="0" selected>no</option>
              </select>
            </td>
          </tr>
          <tr>
            <th>Flip <div class="help" data-topic="pop_dl_flip"></div></th>
            <td>
              <select id="dl_flip">
                <option value="1">yes</option>
                <option value="0" selected>no</option>
              </select>
            </td>
          </tr>
          <tr>
            <th>Width <div class="help" data-topic="pop_dl_width"></div></th>
            <td>
              <input name="width" id="dl_width" type="text" size="3" placeholder="auto"/>
            </td>
          </tr>
          <tr>
            <th>Height <div class="help" data-topic="pop_dl_height"></div></th>
            <td>
              <input name="height" id="dl_height" type="text" size="3" placeholder="auto"/>
            </td>
          </tr>
        </table>
        <input type="submit" id="download_submit" value="download"/>&nbsp;&nbsp;<input type="button" id="download_cancel" value="cancel"/>
      </form>
      <script>make_logo_form()</script>
    </div>

    <div class="pad1">
    <div class="prog_logo big">
    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAIAAABMXPacAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wLHAI4Nh+WUs4AAAA8dEVYdENvbW1lbnQAIEltYWdlIGdlbmVyYXRlZCBieSBHTlUgR2hvc3RzY3JpcHQgKGRldmljZT1wbm1yYXcpCszMtoUAACAASURBVHja7L13nF5llQf+Pee5963Te2bSew9JSC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wAwY8aM4uJi13Vx+K723HgZY7TWGzZsqKysrK6uBsBsyAaqcFw8PfCHo8ecPmHoiadkZ2f16Jnn6ABYHWiE7wk7llNCpPyMTBV0SbEpLHBE/MsumxqKRGbdcluvXr0ADmaK61qOuwHI96i5iaE1EdjIgcZoJOJFo+Ha2up5C+5b+syjgAv4pAwIYkDkBAJUUTHwjTfeEBH7tQ/XJGjnna9dTGOx2KpVq35+yZTGAyGttFLM4sVb3ZZIotyiwqLikm6lpd1//KNRpV17DBv2o4zcIDNiUYCQmYlgEBBT2ElrBdcFCL4PFrAgI9j670bD2LJl2zub3/ryy10rVz7f3BTaU7tr//7dsMYPkvKPZSMi/OCDD06ePNlyLA7X6t8hA5DEiJhZK33dtTc99ufFX1Z/ZtH/5F4FRFqDWQlLelRZMFDcf8DA3NxcIuO4ynW16yqAFQwn4VIxWmvDMH40EgnV1NRu374jHG5IA0hcAiRuWiZo0TuTH/yg/6JFiwYNGuh5nta6o3vu37TB276XBeJ93xMxzU0NS5+pys3JTsJHWjlAAAjGnRhtDBvFX9PK01cYYVOL6kVkw3W15e4n76dSpBQlTC/sR+uqqqfD4QizsVdS8XIYr/YfAPurEq+S/IlLliw555xzkuxax9EdO7XTxBTdunWbOXNmOBxq86v+fxuANidELBZj5lgsFolE7r///o5GfZMLS+fOnRcvXszMnud5nidH3tXh8FPKtY1S/lUAtm7d+uabb7700ktr166tq6trcbJt+d+RkuhIq7el/6tSyiSocX369LnoootGjRp1wgknWICh1V8/cq7vGv9LGIjFlym7B//000+XLl26du3aLVu22Fni+34SLfgakNJuYLTWwWAwEAj07du3srJy4sSJubm5duY5KYXNEXodBgC2VdRrOgzg+35dXV19fX1zc3N1dfUnn3xSW1u7Z8+eurq6aDSaRG/y8/PLyspKSkqKioqOPfbYoqKigoKCwsJCS2BJvg0dTyw89Ot/AHy3hsLr1jX2AAAAAElFTkSuQmCC" alt="Tomtom Logo">
    <h1>Tomtom</h1>
    <h2>Motif Comparison Tool</h2>
    </div>
    <p>
      For further information on how to interpret these results please access
      <a href="http://meme-suite.org/doc/tomtom-output-format.html">http://meme-suite.org/doc/tomtom-output-format.html</a>.<br />
      To get a copy of the MEME software please access 
      <a href="http://meme-suite.org">http://meme-suite.org</a>.
    </p>
    <p>If you use TOMTOM in your research, please cite the following paper:<br>
      <span class="citation">
        Shobhit Gupta, JA Stamatoyannopolous, Timothy Bailey and William Stafford Noble,
        "Quantifying similarity between motifs",
        <i>Genome Biology</i>, <b>8</b>(2):R24, 2007.
        <a href="http://genomebiology.com/2007/8/2/R24">[full text]</a>
      </span>
    </p>
    </div>

    <div class="pad2">
      <a class="jump" href="#query_motifs">Query Motifs</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a
        class="jump" href="#target_dbs">Target Databases</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a
        class="jump" href="#matches">Matches</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a
        class="jump" href="#settings">Settings</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a
        class="jump" href="#program">Program information</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a
        class="jump" href="tomtom.tsv">Results in TSV Format</a>&nbsp;<span id="results_tsv"></span>&nbsp;<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAQCAMAAAAyEe/dAAAACVBMVEX//wAAAAD////s2cV/AAAAdUlEQVQYlXVRBxLAIAhL+P+jC2HZhXcBZEWEldDsZcLIcAhHWWnK8SDcWQhMFUHdAQ1CqQ5+CWPmlHojl+nCJNRtzu4qRc3IUzmTVpXYK0nox0z0PI1stgchdK7lEv7ekhvalw8WW547Gyzedt/2/gLx8WXjXF/1AYFriNAWAAAAAElFTkSuQmCC" alt="NEW" id="new_1">
          &nbsp;&nbsp;|&nbsp;&nbsp;<a
        class="jump" href="tomtom.xml">Results in XML Format</a>
      <script>
        make_help_button($("results_tsv"), "pop_results_tsv");
      </script>
    </div>

    <div id="query_motifs" class="header">
      <h2>Query Motifs</h2>
      <span><a href="#target_dbs">Next</a>&nbsp;<a href="#">Top</a></span>
    </div>
    <div class="box">
      <table id="preview" class="preview th_ul">
        <thead>
          <tr>
          <th><span>Database <div class="help" data-topic="pop_query_db"></div></span></th>
          <th><span>ID <div class="help" data-topic="pop_query_name"></div></span></th>
          <th><span>Alt. ID <div class="help" data-topic="pop_query_alt"></div></span></th>
          <th><span>Preview <div class="help" data-topic="pop_query_preview"></div></span></th>
          <th><span>Matches <div class="help" data-topic="pop_query_matches"></div></span></th>
          <th><span>List <div class="help" data-topic="pop_query_list"></div></span></th>
          </tr>
        </thead>
        <tbody>
          <tr class="pview_row">
          <td class="pview_db"></td>
          <td class="pview_name"></td>
          <td class="pview_alt"></td>
          <td class="pview_logo"></td>
          <td class="pview_matches"></td>
          <td><div class="ml pview_list"></div></td>
          </tr>
        </tbody>
      </table>
      <script>make_preview();</script>
    </div>

    <div id="target_dbs" class="header">
      <h2>Target Databases</h2>
      <span><a href="#query_motifs">Previous</a>&nbsp;<a id="link_after_target_db" href="#">Next</a>&nbsp;<a href="#">Top</a></span>
    </div>
    <div class="box">
      <table id="tdbs" class="targets th_ul">
      <thead>
        <tr>
          <th><span>Database <div class="help" data-topic="pop_db_name"></div></span></th>
          <th><span>Used <div class="help" data-topic="pop_db_used"></div></span></th>
          <th><span>Matched <div class="help" data-topic="pop_db_matched"></div></span></th>
        </tr>
      </thead>
      <tbody>
        <tr class="db_row">
          <td class="db_name"></td>
          <td class="db_used ac"></td>
          <td class="db_matched ac"></td>
        </tr>
      </tbody>
      </table>
      <script>make_target_dbs();</script>
    </div>

    <div id="matches">
      <div class="match_box">
        <div class="header">
          <h2>Matches to <span class="query_name"></span></h2>
          <span class="links"><a class="prev" href="#">Previous</a>&nbsp;<a class="next" href="#">Next</a>&nbsp;<a href="#">Top</a></span>
        </div>
        <div class="box">
          <table class="th_ul" style="width:100%">
            <col style="width: 5em;">
            <col>
            <tbody class="match_entry">
              <tr>
                <th style="text-align:left;"><span>Summary <div class="help" data-topic="pop_match_summary"></div></span></th>
                <th style="text-align:left;"><span>Optimal Alignment <div class="help" data-topic="pop_match_alignment"></div></span></th>
              </tr>
              <tr>
                <td style="vertical-align:top">
                  <table class="match_summary">
                    <tbody>
                      <tr>
                        <th>Name <div class="help" data-topic="pop_match_name"></div></th>
                        <td class="match_name"></td>
                      </tr>
                      <tr>
                        <th>Database <div class="help" data-topic="pop_match_db"></div></th>
                        <td class="match_db"></td>
                      </tr>
                    </tbody>
                    <tbody>
                      <tr>
                        <th><i>p</i>-value <div class="help" data-topic="pop_match_pvalue"></div></th>
                        <td class="match_pvalue"></td>
                      </tr>
                      <tr>
                        <th><i>E</i>-value <div class="help" data-topic="pop_match_evalue"></div></th>
                        <td class="match_evalue"></td>
                      </tr>
                      <tr>
                        <th><i>q</i>-value <div class="help" data-topic="pop_match_qvalue"></div></th>
                        <td class="match_qvalue"></td>
                      </tr>
                    </tbody>
                    <tbody>
                      <tr>
                        <th>Overlap <div class="help" data-topic="pop_match_overlap"></div></th>
                        <td class="match_overlap"></td>
                      </tr>
                      <tr>
                        <th>Offset <div class="help" data-topic="pop_match_offset"></div></th>
                        <td class="match_offset"></td>
                      </tr>
                      <tr>
                        <th>Orientation <div class="help" data-topic="pop_match_orientation"></div></th>
                        <td class="match_orientation"></td>
                      </tr>
                    </tbody>
                  </table>
                  <a class="download_text" href="#">Show logo download options</a>
                </td>
                <td>
                  <div class="logo_container">
                    <a title="Previous query" class="prev_query">&#x2912;</a>
                    <a title="Previous match" class="prev_target">&#x21A5;</a>
                    <a title="Show logo download options" class="download_btn">&#x21D8;</a>
                    <a title="Next match" class="next_target">&#x21A7;</a>
                    <a title="Next query" class="next_query">&#x2913;</a>
                  </div>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>
    <script>make_matches();</script>

    <div id="settings" class="header">
      <h2>Settings</h2>
      <span><a id="link_before_program" href="#">Previous</a>&nbsp;<a href="#program">Next</a>&nbsp;<a href="#">Top</a></span>
    </div>
    <div class="box">
      <h4>Alphabet</h4>
      <span id="bg_source"></span>
      <span id="alpha_bg"></span>
      <script>
      {
        $("bg_source").appendChild(make_background_source("Source", data.options.background_source));
        $("alpha_bg").appendChild(make_alpha_bg_table(tomtom_alphabet));
      }
      </script>
      <h4>Other Settings</h4>
      <table id="tbl_settings" class="inputs hide_advanced">
        <tr>
          <th>Strand Handling</th>
          <td id="opt_strand">
            <span class="strand_none">Reverse complements are not possible so motifs are compared as they are provided.</span>
            <span class="strand_given">Motifs are compared as they are provided.</span>
            <span class="strand_both">Motifs may be reverse complemented before comparison to find a better match.</span>
          </td>
        </tr>
        <tr>
          <th>Distance Measure</th>
          <td id="opt_dist">
            <span class="dist_allr">Average log-likelihood ratio</span>
            <span class="dist_ed">Euclidean distance</span>
            <span class="dist_kullback">Kullback-Leibler divergence</span>
            <span class="dist_pearson">Pearson correlation coefficient</span>
            <span class="dist_sandelin">Sandelin-Wasserman function</span>
            <span class="dist_blic1">Bayesian Likelihood 2-Components score (from 1-component Dirichlet prior)</span>
            <span class="dist_blic5">Bayesian Likelihood 2-Components score (from 5-component Dirichlet prior)</span>
            <span class="dist_llr1">Log likelihood Ratio score (from 1-component Dirichlet prior)</span>
            <span class="dist_llr5">Log likelihood Ratio score (from 5-component Dirichlet prior)</span>
          </td>
        </tr>
        <tr>
          <th>Match Threshold</th>
          <td id="opt_ttype">
            Matches must have a <span class="ttype_evalue"><i>E</i>-value</span><span class="ttype_qvalue">q-value</span> of <span id="opt_thresh"></span> or smaller.
          </td>
        </tr>
      </table>
      <script>
      {
        $("opt_strand").className = (tomtom_alphabet.has_complement() ? (data.options.strands == "both" ? "both" : "given") : "none");
        $("opt_dist").className = data.options.distance_measure;
        $("opt_ttype").className = data.options.threshold_type;
        $("opt_thresh").textContent = data.options.threshold_value;
      }
      </script>
    </div>

    <div id="program" class="bar">
      <div style="text-align:right;"><a href="#settings">Previous</a> <a href="#">Top</a></div>
      <div class="subsection">
        <h5>TOMTOM version</h5>
        <span id="version"></span> (Release date: <span id="release"></span>)
      </div>
      <div class="subsection">
        <h5>Reference</h5>
        <span class="citation">
          Shobhit Gupta, JA Stamatoyannopolous, Timothy Bailey and William Stafford Noble,
          "Quantifying similarity between motifs",
          <i>Genome Biology</i>, <b>8</b>(2):R24, 2007.
        </span>
      </div>
      <div class="subsection">
        <h5>Command line</h5>
        <textarea id="cmd" rows="1" style="width:100%;" readonly></textarea><br>
        <br>Result calculation took <span id="runtime"></span> seconds<br>
      </div>
    </div>
    <script>make_program();</script>
  </body>
</html>
